可以通过window.history.length 进行指定回退页面

window.history.length 就是记录你当前的页面进行了多少次访问,当window.history.length等于1的时候就说明已经不能进行回退了,所以在回退的时候可以这样判断

goBack() {
      window.history.length > 1 ? this.$router.go(-1) : this.$router.push('/')
    },

但好像当length达到50的时候 长度就不会再增加了

猜你喜欢

转载自www.cnblogs.com/yanyanliu/p/12931900.html