1、创建js文件,编写获取url参数的方法
export default{
getUrlKey:function(name){
return decodeURIComponent((new RegExp('[?|&]'+name+'='+'([^&;]+?)(&|#|;|$)').exec(location.href)||[,""])[1].replace(/\+/g,'%20'))||null;
}
}
2、在main.js里引入js文件
3、在需要获取url参数的vue文件里使用js方法,id和size都是自定义的参数名称。
4、最终效果,获取到url里的参数,多个参数用&连接起来。