首页 > 解决方案 > 记录 rootState 和组件的挂载钩子中发生的所有突变?

问题描述

我有一个消息组件,只要我的应用程序出现问题,它就会显示一个 errorMessage。我想将完整的 vueX 状态 obj 以及发生这种情况时发生的所有突变记录到我的后端,想知道是否可以在错误组件的挂载钩子中完成。

export default {
  name: 'Error',
  components: { PageHeader },
  mounted() {
    debugger
    console.log('rootState and all prior vueX mutations' ....????); 
  },
  methods: {
}

标签: vue.jsvuex

解决方案


  • 获取根状态:this.$store.state
  • 获取 Vuex 变异列表数组:this.$store._mutations

export default {
  name: 'Error',
  components: { PageHeader },
  mounted() {
    console.log('rootState: ', this.$store.state);
    console.log('Vuex mutations: ', this.$store._mutations);
  },
  methods: {
}


推荐阅读