Vue仿微信app页面跳转动画使用说明
独立开发者在开发移动端产品时,为了更高效,通常会使用Web技术来开发移动端项目,可以同时适配Android、iOS、H5,稍加改动还可适配微信小程序。在使用Vue.js开发移动端页面的时候,默认的组件转场效果过于生硬,根本就没有动画效果。于是我用Vue提供的组件过渡功能,写了个仿微信app页面跳转的动画,以提高用户体验。
废话不多说,直接上图
在600元骁龙632安卓测试机效果流畅。
核心代码
<transition :name="this.$store.routeAction"> <router-view/> </transition>
CSS
.push-enter-active,.push-leave-active , .pop-enter-active,.pop-leave-active{ transition: all 0.4s; } .push-leave-to{ transform: translate(-20%,0); } .push-enter { transform: translate(100%, 0); } .push-enter-active { z-index: 10; } .push-leave-active { z-index: 0; } .pop-leave-active { transform: translate(100%, 0); z-index: 11; } .pop-enter{ transform: translate(-20%,0); }
Vue.js组件过渡相关文档 https://cn.vuejs.org/v2/guide/transitions.html
来自:https://github.com/YellowDoing/vue-route-transition