refactor[errorLog]: save the logs in vuex

This commit is contained in:
Pan
2017-12-13 13:52:14 +08:00
parent f9aaaa9091
commit a68413cb8f
6 changed files with 34 additions and 31 deletions

View File

@@ -1,15 +1,17 @@
import Vue from 'vue'
import errLog from '@/store/errorLog'
import store from './store'
// you can set only in production env show the error-log
// if (process.env.NODE_ENV === 'production') {
Vue.config.errorHandler = function(err, vm, info) {
errLog.pushLog({
err,
vm,
info,
url: window.location.href
Vue.config.errorHandler = function(err, vm, info, a) {
Vue.nextTick(() => {
store.dispatch('addErrorLog', {
err,
vm,
info,
url: window.location.href
})
console.error(err, info)
})
console.error(err, info)
}
// }