具體方法如下:
1.使用params方式獲取地址欄參數
export default new Router({
routes: [
{ path: '/', name: 'LoginView', component: LoginView },
{ path: '/home', name: 'HomeView', component: HomeView }
]
})
this.$route.params.userName
2.采用正則表達式獲取地址欄參數
function GetQueryString(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
alert(GetQueryString("參數名1"));
alert(GetQueryString("參數名2"));
alert(GetQueryString("參數名3"));