
问题就是从一个页面跳转到另一个页面之后,使用 router.go(-1),浏览器地址变了,页面不跳转
最外层 router 如下,导入了 landf:
import lanf from '@/components/LandF/router/index' export default new Router({ mode: 'history', base:base, routes: [ { path: '/', name: 'PageTransition', component: PageTransition, meta: { KeepAlive: false }, children: [ ...lanf ] }] }) 最外层的 PageTransition 组件
<template> <div> <transition :name="transitionName"> <keep-alive include="landf"> <router-view class="child-view"></router-view> </keep-alive> </transition> </div> </template> <script> export default { data () { return { transitionName: 'slide-left', } }, beforeRouteUpdate (to, from, next) { if (isBack) { this.transitiOnName= 'slide-right' } else { this.transitiOnName= 'slide-left' } next() } } </script> 然后是内层的 landf router:
export default [ { path: '/', name: 'landf', component:index, }, { path:'/detail/:id', name:'landfitemdetail', component:detail, } ] 然后当我从 landf 点击事件跳转到 detail
this.$router.push({ name:'landfitemdetail', params:{ id:id, state:state } }) } 一切正常。。。。。 但是,当我从 detail 点击返回..............
goback(){ this.$router.back(-1) } 可以看见浏览器的地址已经改变了,然而页面并没有任何变动。。。再点击一次,就回到我的 chrome 首页了。。。。 求救啊~!!!!!!!
1 notes 2017-10-05 23:01:49 +08:00 via Android 额,看不出问题,也许 this.$route 用法出错 |
3 CupTools 2017-10-06 02:42:38 +08:00 via iPhone PageTransititon 里面的 isBack 是哪来的时候♀ |
4 xiaojie668329 2017-10-06 09:01:41 +08:00 via iPhone this.$router.back()就是后退,等于 this.$router.go(-1),没有 back(-1)这种写法吧。 |
5 gogobody OP @CupTools 额,这个是我自己定义的。那个我找到原因了,我在 befrerouteleave 里面把当前组件 destroy 了,然后导致了无法 go(-1)到前一个页面,请问是啥原因呢 |
6 gogobody OP @xiaojie668329 我在 befrerouteleave 里面把当前组件 destroy 了,然后导致了无法 go(-1)到前一个页面,请问是啥原因呢 |