errorLog.js 544 字节
Newer Older
P
Pan 已提交
1
import Vue from 'vue'
P
Pan 已提交
2
import store from './store'
P
Pan 已提交
3

P
Pan 已提交
4 5
// you can set only in production env show the error-log
// if (process.env.NODE_ENV === 'production') {
花裤衩 已提交
6

P
Pan 已提交
7
Vue.config.errorHandler = function(err, vm, info, a) {
花裤衩 已提交
8 9
  // Don't ask me why I use Vue.nextTick, it just a hack.
  // detail see https://forum.vuejs.org/t/dispatch-in-vue-config-errorhandler-has-some-problem/23500
P
Pan 已提交
10 11 12 13 14 15 16 17
  Vue.nextTick(() => {
    store.dispatch('addErrorLog', {
      err,
      vm,
      info,
      url: window.location.href
    })
    console.error(err, info)
P
Pan 已提交
18
  })
P
Pan 已提交
19
}
花裤衩 已提交
20

P
Pan 已提交
21
// }