1. 使用

+ 在app.vue中用keep-alive将router-view包裹起来
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>
+ 在router.js中处理
    {
        path: '/foodDeal/info',
        component: resolve => require(['@/views/foodDeal/info'], resolve),
        meta: { keepAlive: false }
    },

注意: 缓存的页面钩子失效,必须使用activated和deactivated

        activated() {
        	// 显示
            console.log(1);
        },
        deactivated() {
        	// 不显示
            console.log(2);
        },
Logo

前往低代码交流专区

更多推荐