Vue: Transition keep alive

Created on 9 Aug 2016  路  1Comment  路  Source: vuejs/vue

Vue.js version

2.0.0-beta7

Reproduction Link

https://jsfiddle.net/miljan/yfLprk1t/

Steps to reproduce

Open the console and change the current visible Tab with the buttons.

What is Expected?

That created event is triggered only once

What is actually happening?

Is trigerred each time the component is displayed.

Most helpful comment

This is an interesting use case because keep-alive as an attribute doesn't work well for multiple conditional nodes.

I've adjusted it to use a component-based API similar to <transition> (will be out in next release):

<tabs>
  <transition>
    <keep-alive>
      <tabs-item v-if="index === 0" key="tab-1">Tab 1</tabs-item>
      <tabs-item v-if="index === 1" key="tab-2">Tab 2</tabs-item>
      <tabs-item v-if="index === 2" key="tab-3">Tab 3</tabs-item>
    <keep-alive>
  </transition>
</tabs>

>All comments

This is an interesting use case because keep-alive as an attribute doesn't work well for multiple conditional nodes.

I've adjusted it to use a component-based API similar to <transition> (will be out in next release):

<tabs>
  <transition>
    <keep-alive>
      <tabs-item v-if="index === 0" key="tab-1">Tab 1</tabs-item>
      <tabs-item v-if="index === 1" key="tab-2">Tab 2</tabs-item>
      <tabs-item v-if="index === 2" key="tab-3">Tab 3</tabs-item>
    <keep-alive>
  </transition>
</tabs>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

wufeng87 picture wufeng87  路  3Comments

julianxhokaxhiu picture julianxhokaxhiu  路  3Comments

fergaldoyle picture fergaldoyle  路  3Comments

bfis picture bfis  路  3Comments

aviggngyv picture aviggngyv  路  3Comments