当前位置:网站首页>Cache page keepalive use in Vue

Cache page keepalive use in Vue

2022-06-26 15:05:00 A Taurus cub

  1. Configure... In the route
      {
    
        path: '',
        name: 'xx',
        meta: {
     keepAlive: true },
        component: xx
      },
  1. stay App.vue Middle configuration
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive" :key="key">
    </router-view>
    
    computed: {
    
	    key() {
    
	      return this.$route.path + Math.random();
	    },
	  },
  1. Unique life cycle
// Triggered on entry 
activated() {
    }
// Trigger on exit 
deactivated() {
    }

keepAlive It also supports many functions , You need to check it yourself

原网站

版权声明
本文为[A Taurus cub]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261447181342.html