javascript - vue routing animation problem
大家讲道理
大家讲道理 2017-05-19 10:35:40
0
3
477
<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'
        }
      }

My whole page only has one <router-view></router-view>. Is it impossible to make the route that is about to disappear disappear from the left and the route that is about to come in from the right when switching routes?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
阿神

Add transition directly to the component

大家讲道理

Do you want to simulate the route switching method of APP

I recently wanted to do a small project. It is still a semi-finished product, but the transition part has already implemented this operation. You can go and see if it is what you want

https://github.com/tgxpuisb/vue-open-use

滿天的星座

Set the mode to out–in

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template