Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue Router Keep-Alive Include not working

I've a Vue Router like this:

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Inbox',
      component: Inbox
    }]
})

In the main app.vue I've:

  <div id="app">
    <main>
      <keep-alive include="Inbox">
        <router-view></router-view>
      </keep-alive>
    </main>
  </div>

It won't work, but if I remove the include it works (in all routes). What is missing here for the keep-alive only work in the Inbox component?

like image 332
InfoStatus Avatar asked Apr 04 '18 14:04

InfoStatus


1 Answers

Your route is named but your component is not, therefore keep-alive include="Inbox" is not applying to any components.

The fix is to add name: 'Inbox' to your component definition for Inbox

like image 188
sliptype Avatar answered Oct 23 '22 06:10

sliptype