【发布时间】:2018-07-05 06:24:27
【问题描述】:
我有 3 个组件,我想在它们进入/离开时显示过渡效果。
当您按下相关按钮时,会显示 1 个“主要”组件和另外 2 个组件。我当前的示例代码在这里:https://jsfiddle.net/5aq1k05L/
<transition :name="'step_' + currentView" mode="out-in">
<component :is="currentView"></component>
</transition>
CSS:
.step_componentA-enter-active {
transition: transform 0.4s;
}
.step_componentA-leave-active {
transition: transform 0s;
}
.step_componentA-enter {
transform: translateX(-100%);
}
.step_mainComponent-leave-active {
transition: transform 0.3s;
}
.step_mainComponent-leave-to {
transform: translateX(-100%);
}
.step_componentB-enter-active {
transition: transform 0.4s;
}
.step_componentB-leave-active {
transition: transform 0s;
}
.step_componentB-enter {
transform: translateX(100%);
}
我想要做什么:
当我单击“componentA”按钮时,我希望该组件在过渡期间从左侧滑动,而“mainComponent”在背景中仍然可见(不像现在那样被去除元素)。
“componentB”也一样,只是它会从右侧滑动,点击返回时会回到右侧。
我错过了什么? https://jsfiddle.net/5aq1k05L/
【问题讨论】:
-
@tony19 确实如此。我已经更新了帖子。谢谢!
标签: css vue.js vuejs2 css-transitions vuejs-transition