Vue: [Suggestion] Allow to force transition on dynamic components

Created on 7 Apr 2016  Â·  4Comments  Â·  Source: vuejs/vue

Related to #2633. Sometimes we need to force apply transition when switching dynamic components. Example: https://jsfiddle.net/Lnnju3ej/5/ When click to button 3 transition not apply because of the same component.

Most helpful comment

If anyone stumbles upon this I solved it by simply adding a dynamic key to the component so that a data change would remount it.

<component :is="componentType" :key="somethingThatChanges"/>

Not sure if this is the most elegant way to solve it.

All 4 comments

I think forcing transition in this case doesn't quite make sense because the component did not really change.

What you are really trying to achieve is dynamically switching between content with transitions rather than components. In 1.1 we will probably come up with a new mechanism specifically to deal with this scenario, and in the meanwhile you can somewhat simulate it with a v-for with just a single item.

In 1.1 we will probably come up with a new mechanism specifically to deal with this scenario, and in the meanwhile you can somewhat simulate it with a v-for with just a single item.

Hey @yyx990803 was this ever implemented?

If anyone stumbles upon this I solved it by simply adding a dynamic key to the component so that a data change would remount it.

<component :is="componentType" :key="somethingThatChanges"/>

Not sure if this is the most elegant way to solve it.

@PierBover thank you for sharing the hint about :key.

Was this page helpful?
0 / 5 - 0 ratings