Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js vue路由器相同页面刷新_Vue.js_Vuejs2_Vue Router - Fatal编程技术网

Vue.js vue路由器相同页面刷新

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,

我想从下面的URL转到这个。但它不起作用,下面是代码:

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将跨路由更改重用相同的组件实例,因此当路由更改时,不会调用创建的
和装入的
挂钩。