vue页面切换过渡transition效果
网络编程 2021-07-04 16:46www.168986.cn编程入门
这篇文章主要介绍了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; 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效果,希望对大家有所帮助,如果大家有任何疑问请给我留言,长沙网络推广会及时回复大家的。在此也非常感谢大家对狼蚁SEO网站的支持!
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程