【发布时间】:2018-08-01 02:22:18
【问题描述】:
我在 vueJS 中有一个单页应用:
let router = new VueRouter({
routes: [
{ path: '/', component: Dis13HomeComponent },
{ path: '**', component: Dis13HomeComponent }
]
});
在mounted() 的主要组件中,我得到这样的url 参数:
this.$route.query.token;
但是如果我打开 http://www.myapp.com/app.html?token=s56ds6d5d56f6ef6e 它不会读取令牌参数,因为 vue 正在将 #/ 添加到 url 的末尾,所以它看起来像 http://www.myapp.com/app.html?token=s56ds6d5d56f6ef6e#/
如果我打开这种格式的 url:http://www.myapp.com/app.html#/?token=s56ds6d5d56f6ef6e,那么它可以工作,但是这个路径在服务器上是被禁止的。
如何读取令牌参数?
【问题讨论】:
标签: vue.js routing routes url-parameters