Skip to content

Commit

Permalink
fix(h5): App.vue onError
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Jul 13, 2019
1 parent 55d307b commit 74b6eb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
22 changes: 9 additions & 13 deletions src/core/service/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import VueRouter from 'vue-router'

import {
isFn
} from 'uni-shared'

import {
isPage
} from 'uni-helpers'
Expand Down Expand Up @@ -59,7 +55,7 @@ function getLocation (base = '/') {
export default {
install (Vue, {
routes
} = {}) {
} = {}) {
lifecycleMixin(Vue)

const minId = getMinId(routes)
Expand Down Expand Up @@ -106,11 +102,11 @@ export default {
/* eslint-disable no-undef */
if (__PLATFORM__ === 'h5') {
if (entryRoute.meta && entryRoute.meta.name) {
document.body.className = 'uni-body ' + entryRoute.meta.name
if (entryRoute.meta.isNVue) {
const nvueDirKey = 'nvue-dir-' + __uniConfig.nvue['flex-direction']
document.body.setAttribute('nvue', '')
document.body.setAttribute(nvueDirKey, '')
document.body.className = 'uni-body ' + entryRoute.meta.name
if (entryRoute.meta.isNVue) {
const nvueDirKey = 'nvue-dir-' + __uniConfig.nvue['flex-direction']
document.body.setAttribute('nvue', '')
document.body.setAttribute(nvueDirKey, '')
}
}
}
Expand All @@ -136,10 +132,10 @@ export default {
options.router = router

// onError
if (!isFn(options.onError)) {
options.onError = function (err) {
if (!Array.isArray(options.onError) || options.onError.length === 0) {
options.onError = [function (err) {
console.error(err)
}
}]
}
} else if (isPage(this)) {
const pageMixin = createPageMixin()
Expand Down
2 changes: 1 addition & 1 deletion src/core/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ Vue.config.getTagNamespace = function (tag) {
}

Vue.config.errorHandler = function (err, vm, info) {
console.error('errorHandler', err, vm, info)
UniServiceJSBridge.emit('onError', err)
}

0 comments on commit 74b6eb5

Please sign in to comment.