在app.vue中,使用keep-alive,它的属性include,来缓存组件

vue中使用vuex缓存组件

配合使用vuex,来添加需要缓存的组件

vue中使用vuex缓存组件

在需要做缓存的组件内使用
1,引入vuex
2,触发mutations 里的 addCachePage 方法,
this.$store.commit(‘addCachePage’, ‘test’);
3,注意:组件的name:‘test’必须带上,

4,移除缓存触发mutations 里的 removeCachePage方法,
this.$store.commit(‘removeCachePage’, ‘test’) 即可

相关文章:

  • 2021-12-02
  • 2021-05-31
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
  • 2021-04-20
相关资源
相似解决方案