fe-drone-ci/src/errorLog.js

22 lines
544 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
// 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
Vue.nextTick(() => {
store.dispatch('addErrorLog', {
err,
vm,
info,
url: window.location.href
})
console.error(err, info)
2017-12-12 10:14:31 +00:00
})
2017-08-21 07:55:46 +00:00
}
2017-12-12 10:14:31 +00:00
// }