vue页面切换过渡transition效果
2019/6/26 23:25:33
本文主要是介绍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效果,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对找一找教程网网站的支持!
这篇关于vue页面切换过渡transition效果的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-30React Native常用组件-点击组件
- 2024-05-30uniapp+vue3+uv-ui手机端后台OA管理模板
- 2024-05-29Python网络爬虫的时候json=就是让你少写个json.dumps()
- 2024-05-27React Native常用组件-展示组件
- 2024-05-27React Native常用组件-列表组件
- 2024-05-09vue3开发前端表单缓存自定义指令,移动端h5必备插件
- 2024-05-09React Hooks在class组件中的使用方式
- 2024-03-30[OIDC in Action] 2. 基于OIDC(OpenID Connect)的SSO(纯JS客户端)
- 2024-03-29terraform jsonencode
- 2024-03-13vuex-persist