最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

vue页面切换过渡transition效果

来源:懂视网 责编:小采 时间:2020-11-27 22:06:34
文档

vue页面切换过渡transition效果

vue页面切换过渡transition效果:首先得有你想要的过渡效果css代码: .vux-pop-out-enter-active, .vux-pop-out-leave-active, .vux-pop-in-enter-active, .vux-pop-in-leave-active { will-change: transform; transition: all 500ms
推荐度:
导读vue页面切换过渡transition效果:首先得有你想要的过渡效果css代码: .vux-pop-out-enter-active, .vux-pop-out-leave-active, .vux-pop-in-enter-active, .vux-pop-in-leave-active { will-change: transform; transition: all 500ms

首先得有你想要的过渡效果css代码:

.vux-pop-out-enter-active,
.vux-pop-out-leave-active,
.vux-pop-in-enter-active,
.vux-pop-in-leave-active {
 will-change: transform;
 transition: all 500ms;
 height: 100%;
 position: absolute;
 backface-visibility: hidden;
 perspective: 1000;
}
.vux-pop-out-enter {
 opacity: 0;
 transform: translate3d(-100%, 0, 0);
}
.vux-pop-out-leave-active {
 opacity: 0;
 transform: translate3d(100%, 0, 0);
}
.vux-pop-in-enter {
 opacity: 0;
 transform: translate3d(100%, 0, 0);
}
.vux-pop-in-leave-active {
 opacity: 0;
 transform: translate3d(-100%, 0, 0);
}

给你想要过渡页面的父元素给上这样的样式:

.router-view{
 width: 100%;
 position: absolute;
 -webkit-transition: all .3s cubic-bezier(.55,0,.1,1);
 -moz-transition: all .3s cubic-bezier(.55,0,.1,1);
 -ms-transition: all .3s cubic-bezier(.55,0,.1,1);
 -o-transition: all .3s cubic-bezier(.55,0,.1,1);
 transition: all .3s cubic-bezier(.55,0,.1,1);
 height:100%;
 }

html代码是这样的:

<template>
 <div id="app">
 <transition :name="transitionName"> 
 <router-view class="router-view"></router-view>
 </transition>
 </div>
</template>

js代码是这样的:

export default {
 name: 'app',
 data(){
 return {
 transitionName:'vux-pop-in'
 }
 },
 }

这里的transitionName根据自己的需要去改变,我是监听路由去改变是vux-pop-in还是vux-pop-out的。

watch:{
 $route(to, from) {
 if(to.meta.index > from.meta.index){
 this.transitionName = 'vux-pop-in';
 }else{
 this.transitionName = 'vux-pop-out';
 }
 }
 }

这里当然要个路由这是参数index,分级。

总结

以上所述是小编给大家介绍的vue页面切换过渡transition效果,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

文档

vue页面切换过渡transition效果

vue页面切换过渡transition效果:首先得有你想要的过渡效果css代码: .vux-pop-out-enter-active, .vux-pop-out-leave-active, .vux-pop-in-enter-active, .vux-pop-in-leave-active { will-change: transform; transition: all 500ms
推荐度:
标签: VUE 过渡效果 过渡
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top