Vue.js vue路由器相同页面刷新
我想从下面的URL转到这个。但它不起作用,下面是代码:Vue.js vue路由器相同页面刷新,vue.js,vuejs2,vue-router,Vue.js,Vuejs2,Vue Router,我想从下面的URL转到这个。但它不起作用,下面是代码: export default new Router({ mode: 'hash', linkActiveClass: 'open active', scrollBehavior: () => ({ y: 0 }), routes: [ { path: '/', redirect: '/scenarios/:id', component: Full,
export default new Router({
mode: 'hash',
linkActiveClass: 'open active',
scrollBehavior: () => ({ y: 0 }),
routes: [
{
path: '/',
redirect: '/scenarios/:id',
component: Full,
beforeEnter: beforeEnter,
children: [{
path: '/scenarios/:id',
name: 'Scenario',
component: Scenario
}]
}
]
})
如何使其工作?如果我正确理解您的问题,则是当id更改时,您的路线没有使用新数据进行更新 要解决此问题,您可以查看路由的更改,或将其合并到beforeRouteUpdate挂钩中,路由器文档很好地解释了它:
不清楚到底是什么不起作用。你能提供一份工作吗?我猜您可能没有响应组件中的钩子;Vue将跨路由更改重用相同的组件实例,因此当路由更改时,不会调用创建的
和装入的挂钩。