Is there any mature scheme to realize the smooth transition of ios during vue route handover?

is there any mature scheme to realize the smooth transition of vue when switching ios routes

try to add an index to the route and store it in sessionStorage, so that the clicked index value remains unchanged, and the index of the newly added route increases by 1. At the same time, count+1, makes a regular transition between left and right
homepage-> personal Center-> bind the account by comparing the size of the index value, the large one to the right and the small one to the left. No problem, but there was a problem when I returned to the personal center from the binding account page.

is there any mature plan?

May.27,2021

you want to achieve the effect of native stack, but the routing of vue is based on h5 history. Online thinking:


stack is not a very good solution. Normally, if you enter the list page from the home page, it will be OK to return, but there will be a problem when the list page is refreshed directly and then go back to the home page.

so one solution is to define several arrays, define the transition order of possible pages from front to back, and then traverse these arrays when the route changes. Find the order of the two routes in the array to decide which animation to use


I just did an app project and used this method.
you can customize a meta index, in app.vue, to compare the current index and from index, to add to transition from slide-right or slide-left.

< H1 > app.vue < / H1 >
<template>
  <div id="app">
    <transition :name="transitionName">
        <router-view class="child-view"></router-view>
    </transition>
  </div>
</template>

<script>
export default {
  name: 'app',
  data() {
    return {
      transitionName: ''
    }
  },
  watch: {
    $route(to, from) {
      if (to.meta.index > 0) {
        if (to.meta.index < from.meta.index) {
          this.transitionName = 'slide-right'
        } else {
          this.transitionName = 'slide-left'
        }
      } else if (to.meta.index === 0 && from.meta.index > 0) {
        this.transitionName = 'slide-right'
      }
    }
  }
}
< H2 > router < / H2 >
export default new Router({
  routes: [
    {
      path: '/',
      name: 'home',
      component: resolve => require(['../page/home'], resolve),
      meta: {
        index: 0
      }
    },
    {
      path: '/center',
      name: 'center',
      component: resolve => require(['../page/center'], resolve),
      meta: {
        index: 1
      }
    },
    {
      path: '/account',
      name: 'account',
      component: resolve => require(['../page/account'], resolve),
      meta: {
        index: 2
      }
    }
  ]
})
< H2 > Route switching Animation < / H2 >
.child-view {
  position: absolute;
  width: 100%;
  height: 100%;
}

.slide-right-enter-active,
.slide-right-leave-active,
.slide-left-enter-active,
.slide-left-leave-active {
  will-change: transform;
  transition: all 0.45s ease-out;
  position: absolute;
}

.slide-right-enter {
  opacity: 0;
  transform: translate(-100%, 0);
}

.slide-right-leave-active {
  opacity: 0;
  transform: translate(0%, 0);
}

.slide-left-enter {
  opacity: 0;
  transform: translate(100%, 0);
}

.slide-left-leave-active {
  opacity: 0;
  transform: translate(0%, 0);
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ebc9bd-28eb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ebc9bd-28eb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?