背景:从react中跳转到jq页面,去要取url中?号后面的值:
解决方法:
// 获取当前路径下?问号后边的值 export const getQueryString = (name) => { const reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`); const index = window.location.href.indexOf('?'); const r = window.location.href.substr(index + 1).match(reg); if (r) return unescape(r[2]); return null; };