admin管理员组文章数量:1428671
I'm trying to create a Vue.js transition where one ponent slides in as the other one slides out. I currently have the new ponent ponent sliding in the way I want, but I've been unable to get the old ponent to slide out.
The transition effect I'm going for is similar to the one here at TakeCareOf.
<transition name="slide-fade">
<reservation-step step="1" :showBack="false">
<space-selection/>
</reservation-step>
</transition>
<transition name="slide-fade">
<reservation-step step="2">
<reservation-type/>
</reservation-step>
</transition>
<transition name="slide-fade">
<reservation-step step="3">
<date-selection/>
</reservation-step>
</transition>
<style lang='scss'>
.slide-fade-enter-active,
.slide-fade-leave-active {
transition: all 1s 0.2s;
}
.slide-fade-enter, .slide-fade-leave-active
/* .slide-fade-leave-active below version 2.1.8 */ {
opacity: 0;
}
.slide-fade-enter {
transform: translateX(100px);
}
.slide-fade-leave-active {
transform: translateX(-100px);
}
</style>
I'm trying to create a Vue.js transition where one ponent slides in as the other one slides out. I currently have the new ponent ponent sliding in the way I want, but I've been unable to get the old ponent to slide out.
The transition effect I'm going for is similar to the one here at TakeCareOf.
<transition name="slide-fade">
<reservation-step step="1" :showBack="false">
<space-selection/>
</reservation-step>
</transition>
<transition name="slide-fade">
<reservation-step step="2">
<reservation-type/>
</reservation-step>
</transition>
<transition name="slide-fade">
<reservation-step step="3">
<date-selection/>
</reservation-step>
</transition>
<style lang='scss'>
.slide-fade-enter-active,
.slide-fade-leave-active {
transition: all 1s 0.2s;
}
.slide-fade-enter, .slide-fade-leave-active
/* .slide-fade-leave-active below version 2.1.8 */ {
opacity: 0;
}
.slide-fade-enter {
transform: translateX(100px);
}
.slide-fade-leave-active {
transform: translateX(-100px);
}
</style>
Share
Improve this question
asked Jul 3, 2019 at 16:05
jamesctuckerjamesctucker
431 silver badge8 bronze badges
1 Answer
Reset to default 3This is more of a css animation question than vue.js, but I hope this example is help to you. On JSFiddle . For more information check the official vue translations documentation
template
<link href="https://cdn.jsdelivr/npm/[email protected]" rel="stylesheet" type="text/css">
<div id="transition-ponents-demo">
<p>A <input name="ponent" type="radio" value="v-a" v-model="view"></p>
<p>B <input name="ponent" type="radio" value="v-b" v-model="view"></p>
<transition
name="slide"
>
<ponent v-bind:is="view"></ponent>
</transition>
</div>
vue code
new Vue({
el: '#transition-ponents-demo',
data: {
view: 'v-a',
},
ponents: {
'v-a': {
template: '<div>Компонент А</div>'
},
'v-b': {
template: '<div>Компонент Б</div>'
}
}
})
css animation
.slide-leave-active,
.slide-enter-active {
transition: 1s;
}
.slide-enter {
transform: translate(100%, 0);
}
.slide-leave-to {
transform: translate(-100%, 0);
}
本文标签: javascriptHow to slidetransition two components in VuejsStack Overflow
版权声明:本文标题:javascript - How to slide-transition two components in Vue.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745528497a2661950.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论