您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)vue移動(dòng)端實(shí)現(xiàn)手機(jī)左右滑動(dòng)入場(chǎng)動(dòng)畫的方法,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
app.vue
<template> <div id="app"> <transition :name="transitionName"> <keep-alive > <router-view v-if="$route.meta.keepAlive" class="Router"></router-view> </keep-alive> </transition > <transition :name="transitionName"> <router-view v-if="!$route.meta.keepAlive" class="Router"></router-view> </transition > <Play></Play> </div> </template> <script>import Play from './components/play' export default { name: 'App', data () { return { transitionName: 'slide-left' } }, watch: { '$route' (to, from) { // 切換動(dòng)畫 let isBack = this.$router.isBack // 監(jiān)聽(tīng)路由變化時(shí)的狀態(tài)為前進(jìn)還是后退 if (isBack === true) { this.transitionName = 'slide-right' // from.meta.keepAlive = false // to.meta.keepAlive = true } else { // from.meta.keepAlive = true // to.meta.keepAlive = false // this.transitionName = 'slide-left' if (this.$route.path.split('/').length < 3) { this.transitionName = 'slide-fade' } else { this.transitionName = 'slide-left' } } this.$router.isBack = false } }, components: { Play } } </script> <style> .Router { font-family: Roboto, Lato, sans-serif; position: absolute; width: 100%; height: 100%; padding-bottom: 60px; transition: all .377s ease; box-sizing: border-box; overflow: auto; } .slide-left-enter, .slide-right-leave-active { opacity: 0; -webkit-transform: translate(100%, 0); transform: translate(100%, 0); } .slide-left-leave-active, .slide-right-enter { opacity: 0; -webkit-transform: translate(-100%, 0); transform: translate(-100% 0); } .ovf { overflow: hidden; } .center { width: 95%; margin: 0 auto; overflow-y: hidden; } li { list-style: none; } </style>
路由配置
{ path: '/playListDetail/:id', name: 'playListDetail', component: pather => require(['../components/playListDetail.vue'], pather), meta: { title: '歌單詳情', keepAlive: true, isBack: false } },
返回事件
back () { this.$router.go(-1) this.$router.isBack = true }
關(guān)于vue移動(dòng)端實(shí)現(xiàn)手機(jī)左右滑動(dòng)入場(chǎng)動(dòng)畫的方法就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。