本文共 1087 字,大约阅读时间需要 3 分钟。
sy_util.js代码:
export default { install (Vue, options) { Vue.prototype.$routerQuery = () => { let href = location.href href = href.replace('%20', '+') let result = { } if (href.indexOf('?') >= 0) { // 取 参数 href = href.slice(href.indexOf('?') + 1) let query = '' // 去除 # 部分 if (href.indexOf('#') >= 0) { query = href.slice(0, href.indexOf('#')) } else { query = href } if (query) { let arr1 = query.split('&') arr1.map(item => { let arr2 = item.split('=') result[arr2[0]] = decodeURIComponent(arr2[1]) }) } } return result } }}
希望文档能帮助到您,最后求个赞,谢谢~
转载地址:http://ngevfk.baihongyu.com/