【问题标题】:Going to child route does not persist VueX state转到子路由不会保持 VueX 状态
【发布时间】:2020-02-17 13:36:54
【问题描述】:

所以我有子路线:

 {path: '/news/:id',
   component: () => import('../views/NewsDetail.vue'), 
   props: true
  },

现在,当我从应用程序中的不同视图/组件转到这条路线时:

 <v-list-item-title class="pb-2"><a :href="'/news/'+this.id">{{title}}</a></v-list-item-title>

然而,在这条路线上,VueX 状态会刷新回基本状态。为什么会这样?

【问题讨论】:

  • 你可以使用 $router.push 吗?我猜你用 :href 重新加载你的窗口和 js 内存

标签: vue.js vuejs2 vuex vue-router


【解决方案1】:

您需要改用router-link

<v-list-item-title class="pb-2">
  <router-link :to="`/news/${id}`">
    {{ title }}
  </router-link>
</v-list-item-title>

【讨论】:

    猜你喜欢
    • 2018-03-24
    • 2018-01-17
    • 2020-11-18
    • 2019-03-18
    • 2013-04-05
    • 2019-11-20
    • 1970-01-01
    • 1970-01-01
    • 2016-02-29
    相关资源
    最近更新 更多