实现该项参数的获取要考虑以下几个方面的事情:
1.浏览器是否满足ES5及ES6的问题
2.要熟悉WEBAPI的一些内置函数及对象,如:
https://developer.mozilla.org/zh-CN/docs/Web/API/Window/location
function loadPageVar (sVar) { return decodeURI(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURI(sVar).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1")); } console.log('路由URL:' + location) console.log('路由URL参数:' + loadPageVar("logintype"))
本次总结如下:
版权声明:《 Vue前端中在main文件中获取全局路由URL及参数 》为漠北星火原创文章,转载请注明出处!
最后编辑:2019-6-11 10:06:20