猿问

vue路由动画问题

<template>
    <transition :name="transitionName">
      <router-view></router-view>
    </transition></template>
const routes = [
  { path: '/home', component: home },
  { path: '/detail', component: detail },
  { path: '/order', component: order },
  { path: '/', component: home }
]
    watch: {        '$route' (to, from) {            const toDepth = to.path.split('/').length;            
    const fromDepth = from.path.split('/').length;            this.transitionName = toDepth < fromDepth ? 'slide-right' : 'slide-left'
        }
      }

我整个页面就一个<router-view></router-view>,是不是无法实现路由切换的时候让即将消失路由从左边消失,即将进来的路由从右边进来?


叮当猫咪
浏览 540回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答