提交 36eeb14a 编写于 作者: Y yurj26

fix(h5): setup onError (question/164798)

上级 f7160f6c
......@@ -157,7 +157,7 @@ export function setupApp(comp: any) {
}
const onLaunch = () => {
injectAppHooks(instance)
const { onLaunch, onShow, onPageNotFound } = instance
const { onLaunch, onShow, onPageNotFound, onError } = instance
const path = route.path.slice(1)
const launchOptions = initLaunchOptions({
path: path || __uniRoutes[0].meta.route,
......@@ -178,6 +178,11 @@ export function setupApp(comp: any) {
invokeArrayFns(onPageNotFound, pageNotFoundOptions)
}
}
if (onError) {
instance.appContext.config.errorHandler = (err) => {
invokeArrayFns(onError, err)
}
}
}
if (__UNI_FEATURE_PAGES__) {
// 等待ready后,再onLaunch,否则直达非首页无法获取到正确的path和query
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册