有没有人能帮忙看一个 Vue.js 的问题啊?[新手] - V2EX
gogobody

有没有人能帮忙看一个 Vue.js 的问题啊?[新手]

  •  
  •   gogobody Oct 5, 2017 3171 views
    This topic created in 3145 days ago, the information mentioned may be changed or developed.

    问题就是从一个页面跳转到另一个页面之后,使用 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 首页了。。。。 求救啊~!!!!!!!

    6 replies    2017-10-06 18:49:56 +08:00
    notes
        1
    notes  
       Oct 5, 2017 via Android
    额,看不出问题,也许 this.$route 用法出错
    gogobody
        2
    gogobody  
    OP
       Oct 5, 2017 via Android
    @notes TT .... 好蛋疼啊
    CupTools
        3
    CupTools  
       Oct 6, 2017 via iPhone
    PageTransititon 里面的 isBack 是哪来的时候♀
    voidcomma
        4
    voidcomma  
       Oct 6, 2017 via iPhone
    this.$router.back()就是后退,等于 this.$router.go(-1),没有 back(-1)这种写法吧。
    gogobody
        5
    gogobody  
    OP
       Oct 6, 2017 via Android
    @CupTools 额,这个是我自己定义的。那个我找到原因了,我在 befrerouteleave 里面把当前组件 destroy 了,然后导致了无法 go(-1)到前一个页面,请问是啥原因呢
    gogobody
        6
    gogobody  
    OP
       Oct 6, 2017 via Android
    @xiaojie668329 我在 befrerouteleave 里面把当前组件 destroy 了,然后导致了无法 go(-1)到前一个页面,请问是啥原因呢
    About     Help     Advertise     Blog     API     FAQ     Solana     3095 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 34ms UTC 08:52 PVG 16:52 LAX 01:52 JFK 04:52
    Do have faith in wha you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86