提交 74b6eb55 编写于 作者: fxy060608's avatar fxy060608

fix(h5): App.vue onError

上级 55d307b6
import VueRouter from 'vue-router' import VueRouter from 'vue-router'
import {
isFn
} from 'uni-shared'
import { import {
isPage isPage
} from 'uni-helpers' } from 'uni-helpers'
...@@ -59,7 +55,7 @@ function getLocation (base = '/') { ...@@ -59,7 +55,7 @@ function getLocation (base = '/') {
export default { export default {
install (Vue, { install (Vue, {
routes routes
} = {}) { } = {}) {
lifecycleMixin(Vue) lifecycleMixin(Vue)
const minId = getMinId(routes) const minId = getMinId(routes)
...@@ -106,11 +102,11 @@ export default { ...@@ -106,11 +102,11 @@ export default {
/* eslint-disable no-undef */ /* eslint-disable no-undef */
if (__PLATFORM__ === 'h5') { if (__PLATFORM__ === 'h5') {
if (entryRoute.meta && entryRoute.meta.name) { if (entryRoute.meta && entryRoute.meta.name) {
document.body.className = 'uni-body ' + entryRoute.meta.name document.body.className = 'uni-body ' + entryRoute.meta.name
if (entryRoute.meta.isNVue) { if (entryRoute.meta.isNVue) {
const nvueDirKey = 'nvue-dir-' + __uniConfig.nvue['flex-direction'] const nvueDirKey = 'nvue-dir-' + __uniConfig.nvue['flex-direction']
document.body.setAttribute('nvue', '') document.body.setAttribute('nvue', '')
document.body.setAttribute(nvueDirKey, '') document.body.setAttribute(nvueDirKey, '')
} }
} }
} }
...@@ -136,10 +132,10 @@ export default { ...@@ -136,10 +132,10 @@ export default {
options.router = router options.router = router
// onError // onError
if (!isFn(options.onError)) { if (!Array.isArray(options.onError) || options.onError.length === 0) {
options.onError = function (err) { options.onError = [function (err) {
console.error(err) console.error(err)
} }]
} }
} else if (isPage(this)) { } else if (isPage(this)) {
const pageMixin = createPageMixin() const pageMixin = createPageMixin()
......
...@@ -23,5 +23,5 @@ Vue.config.getTagNamespace = function (tag) { ...@@ -23,5 +23,5 @@ Vue.config.getTagNamespace = function (tag) {
} }
Vue.config.errorHandler = function (err, vm, info) { Vue.config.errorHandler = function (err, vm, info) {
console.error('errorHandler', err, vm, info) UniServiceJSBridge.emit('onError', err)
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册