search

Home  >  Q&A  >  body text

javascript - vuerouter2使用router.go一直在刷新

代码如下

没有最后一行的时候正常,只是想进来的时候,默认在goods页面,但是页面一直在跳转,不知道是什么问题。看vuerouter的文档没有发现,想默认选中一个该用什么api

PHPzPHPz2872 days ago714

reply all(4)I'll reply

  • 怪我咯

    怪我咯2017-04-17 16:35:38

    { path: '/', component: Goods},

    reply
    0
  • 黄舟

    黄舟2017-04-17 16:35:38

    Redirect

    http://router.vuejs.org/zh-cn...

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 16:35:38

    Add a current default page object in routes:

    const routes = [{
        path: '/', component: Goods
    },{
        path: '/goods', component: Goods
    },{
        path: '/seller', component: Seller
    },{
        path: '/ratings', component: Ratings
    }];

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 16:35:38

    The design pattern of router in vue-router refers to the browser’s window.history related API

    Same as history.go, the parameter accepted by router.go should be Number, for example:

    // 上一页
    history.go(-1)
    router.go(-1)

    And what you should use is router.push

    reply
    0
  • Cancelreply