1. 程式人生 > >vue keep-alive部分快取

vue keep-alive部分快取

因為專案有些頁面不需要快取

<keep-alive>

<router-view v-if="$route.meta.keepAlive"></router-view>

</keep-alive>

<router-view v-if="!$route.meta.keepAlive"></router-view>

 

//...router.js

export default new Router({

routes: [

{ path: '/',

name: 'Hello',

component: Hello,

meta: { keepAlive: false // 不需要快取 }

},

{ path: '/page1',

name: 'Page1',

component: Page1,

meta: { keepAlive: true // 需要被快取 }

}

]

})