qb-admin-fe/src/errorLog.js

20 lines
558 B
JavaScript
Raw Normal View History

2017-08-21 07:55:46 +00:00
import Vue from 'vue'
import store from './store'
2017-08-21 07:55:46 +00:00
2017-12-12 10:14:31 +00:00
// you can set only in production env show the error-log
2018-08-29 03:12:15 +00:00
if (process.env.NODE_ENV === 'production') {
Vue.config.errorHandler = function(err, vm, info, a) {
// 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
2018-08-29 03:12:15 +00:00
Vue.nextTick(() => {
store.dispatch('addErrorLog', {
err,
vm,
info,
url: window.location.href
})
console.error(err, info)
})
2018-08-29 03:12:15 +00:00
}
2017-08-21 07:55:46 +00:00
}