Vue之this.$router.push、replace、go的区别
一. this.$router.push说明:跳转到指定URL,向history栈添加一个新的记录,点击后退会返回至上一个页面this.$router.replace({path: '/index'})二.this.$router.replace说明:跳转到指定URL,替换history栈中最后一个记录,点击后退会返回至上上一个页面使用方法和push相同。this.$router.replace(
·
一. this.$router.push
说明:跳转到指定URL,向history栈添加一个新的记录,点击后退会返回至上一个页面
this.$router.replace({path: '/index'})
二.this.$router.replace
说明:跳转到指定URL,替换history栈中最后一个记录,点击后退会返回至上上一个页面
使用方法和push相同。
this.$router.replace({path: '/index'})
三.this.$router.go(n)
说明:类似window.history.go(n),向前或向后跳转n个页面,n可正(先后跳转)可负(向前跳转)
this.$router.go(1) //类似history.forward()
this.$router.go(-1) //类似history.back()
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)