major697
major697

Reputation: 1862

Vue transition with v-if and v-else not working

I cant add animation using transition or transition-group. I have code:

    <transition mode="out-in" enter-active-class="animated zoomIn" leave-active-class="animated zoomOut">
        <div key=1 v-if="$route.name !== null">
            <router-view></router-view>
        </div>
        <div v-else key=2>
            <p>First text</p>
            <p>Second text</p>
        </div>
    </transition>

the change does not help from transtition to transition-group. Transition should surround:

<div v-if="$route.name !== null">
   <router-view></router-view>
</div>

and

<p>First tex</p>
<p>Second text</p>

Upvotes: 0

Views: 1936

Answers (1)

major697
major697

Reputation: 1862

I found solution. I used transition two times. I do not know if I should do it, but it works now.

    <transition mode="out-in" enter-active-class="animated zoomIn" leave-active-class="animated zoomOut">
        <div key="save" v-if="$route.name !== null">
             <transition mode="out-in" enter-active-class="animated zoomIn" leave-active-class="animated zoomOut">
            <router-view></router-view>
            </transition>
        </div>
        <div v-else key="edit">
           <p>First tex</p>
           <p>Second text</p>
        </div>
    </transition>

Upvotes: 2

Related Questions