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

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

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

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

posted @ 2020-05-21 17:01  纯白棒球帽  阅读(2004)  评论(0编辑  收藏  举报