In the absence of the use of Webpack+vue router development, want to get the Rul pass the parameter address, directly through a function can be obtained.
For example, in a www.test.com/test.html?sign=test address, to get the value of sign, the usual method is to use a function,
var geturlstr = function (name) {
var reg = new RegExp ("(^|&)" + name + "= ([^&]*) (&|$)");
var r = window.location.search.substr (1). Match (REG);
if (r! = null) return unescape (r[2]);
return null;
}
var sign = geturlstr ("sign");
The value of sign is test;
So the problem, with router development, is directly through the route to jump page, then how to get it?
The first thought is also obtained through the above method, but tried, said not feasible. Through Baidu learned that can be directly used to provide the method;
As such, it is the same as the HTTP://LOCALHOST:8080/#/ONE?SIGN=NSRJBXX
var sign = this. $route. Query.sgin;
This refers to the Vue object, so it can be used directly in the Vue method, and sign is the parameter, which is customizable.
Understand very diving, simple can achieve the purpose, have a deeper understanding welcome to comment!!!
VUE+WEBPACK+VUE-CLI get URL Address parameter