封裝一個方法獲取頁面url參數,可作為框架基礎方法使用:
//獲取url參數; 正則獲取url參數,包含hash[#]和search[?]兩種通用
export function getUrlQueryByName(param) {
const reg = new RegExp('(^|&)' + param + '=([^&]*)(&|$)');
const r =
window.location.search.substr(1).match(reg) ||
window.location.hash
.substring(window.location.hash.search(/\?/) + 1)
.match(reg);
if (r != null) {
return decodeURIComponent(r[2]);
}
}
卡布奇諾今猶在,不見當年倒茶人~😌