vue获取url参数
在vue方法里,添加一个方法
methods: { getUrlKey:function(name){ let url= window.location.href; return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(url) || [, ""])[1].replace(/\+/g, '%20')) || null } }
调用:
this.getUrlKey('你要的key');
如果url中参数base64编码
let path = window.location.href.split("?") //分割url
let href = path[0]+"?"+path[1]
let query = Base64.decode(path[1]) //解码
href = path[0]+"?"+ query //解码后重组
this.delivery_asn = getUrlKey("delivery_asn ",href)