簡單的記錄一下以免忘記~
export function getUrlParams<T = {}>() {
const url = window.location.href; // 獲取url中"?"符后的字串
const theRequest: T = {} as T;
if (url.indexOf('?') !== -1) {
const str = url.split('?')[1];
const strs = str.split('&');
for (let i = 0; i < strs.length; i++) {
theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
}
}
return theRequest;
}