errorLog.js 544B

12345678910111213141516171819202122
  1. import Vue from 'vue'
  2. import store from './store'
  3. // you can set only in production env show the error-log
  4. // if (process.env.NODE_ENV === 'production') {
  5. Vue.config.errorHandler = function(err, vm, info, a) {
  6. // Don't ask me why I use Vue.nextTick, it just a hack.
  7. // detail see https://forum.vuejs.org/t/dispatch-in-vue-config-errorhandler-has-some-problem/23500
  8. Vue.nextTick(() => {
  9. store.dispatch('addErrorLog', {
  10. err,
  11. vm,
  12. info,
  13. url: window.location.href
  14. })
  15. console.error(err, info)
  16. })
  17. }
  18. // }