获取浏览器地址栏的值
tool['getQueryValue'] = (queryName) => {
const reg = new RegExp('(^|&)' + queryName + '=([^&]*)(&|$)', 'i')
const r = window.location.search.substr(1).match(reg)
if (r != null) return decodeURI(r[2])
else return null
}
获取路由的值
tool['judgeParams'] = (url, param) => {
const reg = new RegExp('(^|&)' + param + '=([^&]*)(&|$)', 'i')
const index = url.lastIndexOf("?")
const r = url.substring(index + 1, url.length).match(reg)
if (r != null) return decodeURI(r[2])
else return null
}
网友评论