diff --git a/src/components/ErrLog/index.vue b/src/components/ErrLog/index.vue deleted file mode 100644 index 08af0426..00000000 --- a/src/components/ErrLog/index.vue +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - msg:{{ scope.row.err.message }} - - url: {{scope.row.url}} - - - - - {{ scope.row.err.stack}} - - - - - - - - - - - diff --git a/src/components/ErrorLog/index.vue b/src/components/ErrorLog/index.vue new file mode 100644 index 00000000..e30acb3e --- /dev/null +++ b/src/components/ErrorLog/index.vue @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + Msg: + {{ scope.row.err.message }} + + + + Info: + {{scope.row.vm.$vnode.tag}} error in {{scope.row.info}} + + + + Url: + {{scope.row.url}} + + + + + + {{ scope.row.err.stack}} + + + + + + + + + + + diff --git a/src/errorLog.js b/src/errorLog.js index d52c9cab..53f6f16d 100644 --- a/src/errorLog.js +++ b/src/errorLog.js @@ -1,14 +1,15 @@ import Vue from 'vue' -import errLog from '@/store/errLog' +import errLog from '@/store/errorLog' -// 生产环境错误日志 -if (process.env.NODE_ENV === 'production') { - Vue.config.errorHandler = function(err, vm) { - console.log(err, window.location.href) - errLog.pushLog({ - err, - url: window.location.href, - vm - }) - } +// 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 + }) + console.error(err, info) } +// } diff --git a/src/store/errLog.js b/src/store/errorLog.js similarity index 100% rename from src/store/errLog.js rename to src/store/errorLog.js diff --git a/src/views/errorLog/errcode.vue b/src/views/errorLog/errorTestA.vue similarity index 61% rename from src/views/errorLog/errcode.vue rename to src/views/errorLog/errorTestA.vue index 0fa103ce..475c0438 100644 --- a/src/views/errorLog/errcode.vue +++ b/src/views/errorLog/errorTestA.vue @@ -5,3 +5,9 @@ + + diff --git a/src/views/errorLog/errorTestB.vue b/src/views/errorLog/errorTestB.vue new file mode 100644 index 00000000..a1303f89 --- /dev/null +++ b/src/views/errorLog/errorTestB.vue @@ -0,0 +1,11 @@ + + + + + diff --git a/src/views/errorLog/index.vue b/src/views/errorLog/index.vue index 8703bf0a..21f4817d 100644 --- a/src/views/errorLog/index.vue +++ b/src/views/errorLog/index.vue @@ -1,21 +1,26 @@ - + + 请点击右上角bug小图表 - 现在的管理后台基本都是spa的形式了,它增强了用户体验,但同时也会增加页面出问题的可能性,可能一个小小的疏忽就导致整个页面的死锁。好在Vue官网提供了一个方法来捕获处理异常 + 现在的管理后台基本都是spa的形式了,它增强了用户体验,但同时也会增加页面出问题的可能性,可能一个小小的疏忽就导致整个页面的死锁。好在 Vue 官网提供了一个方法来捕获处理异常. + 文档介绍 - + + + diff --git a/src/views/layout/components/Navbar.vue b/src/views/layout/components/Navbar.vue index 2e38703c..14c7c69c 100644 --- a/src/views/layout/components/Navbar.vue +++ b/src/views/layout/components/Navbar.vue @@ -57,8 +57,8 @@ import Breadcrumb from '@/components/Breadcrumb' import Hamburger from '@/components/Hamburger' import ThemePicker from '@/components/ThemePicker' import Screenfull from '@/components/Screenfull' -import ErrorLog from '@/components/ErrLog' -import errLogStore from 'store/errLog' +import ErrorLog from '@/components/ErrorLog' +import errLogStore from '@/store/errorLog' export default { components: {
- 现在的管理后台基本都是spa的形式了,它增强了用户体验,但同时也会增加页面出问题的可能性,可能一个小小的疏忽就导致整个页面的死锁。好在Vue官网提供了一个方法来捕获处理异常 + 现在的管理后台基本都是spa的形式了,它增强了用户体验,但同时也会增加页面出问题的可能性,可能一个小小的疏忽就导致整个页面的死锁。好在 Vue 官网提供了一个方法来捕获处理异常. + 文档介绍