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

 全拼wangziyiva_632 发布于 2022-10-30 03:41

代码如下

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

4 个回答
  • vue-router 中的 router的设计模式是参考了浏览器的window.history相关API

    同history.go, router.go接受的参数应该为Number, 例如:

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

    而你应该使用的是 router.push

    2022-10-31 21:12 回答
  • routes中增加一个当前默认页对象:

    const routes = [{
        path: '/', component: Goods
    },{
        path: '/goods', component: Goods
    },{
        path: '/seller', component: Seller
    },{
        path: '/ratings', component: Ratings
    }];
    2022-10-31 21:12 回答
  • 重定向

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

    2022-10-31 21:12 回答
  • { path: '/', component: Goods},

    2022-10-31 21:12 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有