使用vuex怎样返回上一页?

没使用vuex时方法里面this.$router.back(-1)这样返回上一页 使用了vuex后mutations这样写报错了Cannot read property 'back' of undefined

methods: {
    release () {
      this.$router.back(-1)
    }
  }
mutations: {
    RELEASE () {
      this.$router.back(-1)  //Cannot read property 'back' of undefined
    }
  }
阅读 2.9k
1 个回答

不能使用这样的写法(Vuex只是状态管理),只能在*.vue中使用this.$router。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题