封装一个办法获取页面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]);
}
}
卡布奇诺今犹在,不见当年倒茶人~😌
发表回复