//路由加上

{
    path: 'xxx',
    name: 'xxx',
    component: xxx,
    meta: {
      keepAlive: false // 不需要被缓存,关闭页面在打开时刷新页面
    },
}

//在标签组件里的关闭标签操作上更换状态

 if(!this.$route.meta.keepAlive){
      this.$route.meta.keepAlive = true;
 }else{
     this.$route.meta.keepAlive = false;
 }

//在主页面组件跳转路由DOM设置一个判断语句缓存,一个key重置组件

<div class="article_fast" v-if="!$route.meta.keepAlive" :key="resetKey">
  <keep-alive><router-view ref="pageObject" @changeLogo="changeLogo"></router-view</keep-alive>
</div>

<div v-else class="article_fast" >
          <router-view ref="pageObject" @changeLogo="changeLogo"></router-view
</div>


//在主页面组件路由监听里添加一个操作显示,重置组件
if(this.$route.meta.keepAlive){
    ++this.resetKey;
    this.$route.meta.keepAlive = false;
 }

GitHub 加速计划 / vu / vue
85
16
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:5 个月前 )
9e887079 [skip ci] 3 个月前
73486cb5 * chore: fix link broken Signed-off-by: snoppy <michaleli@foxmail.com> * Update packages/template-compiler/README.md [skip ci] --------- Signed-off-by: snoppy <michaleli@foxmail.com> Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 7 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐