function getParam(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; }
使用:
getParam('xxx');
vue中可使用 this.$route.query.xxx
本文介绍了一种在JavaScript中获取URL参数的方法,并展示了如何在Vue.js中使用路由查询参数。通过正则表达式匹配窗口位置搜索字符串,可以解析并返回指定参数的值。在Vue中,可通过this.$route.query直接访问路由查询参数。
function getParam(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; }
使用:
getParam('xxx');
vue中可使用 this.$route.query.xxx
转载于:https://www.cnblogs.com/linjiangxian/p/11466087.html
628

被折叠的 条评论
为什么被折叠?