From dfd146c292d09cc1faed3c696c2163352145d296 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Tue, 29 Mar 2022 17:29:30 +0800 Subject: [PATCH] fix(mp-baidu): onInit (#3384) --- packages/uni-mp-core/src/runtime/app.ts | 9 +++++++-- packages/uni-shared/src/constants.ts | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/uni-mp-core/src/runtime/app.ts b/packages/uni-mp-core/src/runtime/app.ts index 47fefa764..f9976b6de 100644 --- a/packages/uni-mp-core/src/runtime/app.ts +++ b/packages/uni-mp-core/src/runtime/app.ts @@ -14,6 +14,8 @@ import { ON_THEME_CHANGE, ON_UNHANDLE_REJECTION, ON_SHARE_APP_MESSAGE, + ON_INIT, + ON_READY, } from '@dcloudio/uni-shared' export interface CustomAppInstanceProperty extends Record { @@ -70,8 +72,11 @@ export function parseApp( const vueOptions = instance.$.type as ComponentOptions initHooks(appOptions, HOOKS) - initUnknownHooks(appOptions, vueOptions) - + if (__PLATFORM__ === 'mp-baidu') { + initUnknownHooks(appOptions, vueOptions, [ON_INIT, ON_READY]) + } else { + initUnknownHooks(appOptions, vueOptions) + } if (__VUE_OPTIONS_API__) { const methods = vueOptions.methods methods && extend(appOptions, methods) diff --git a/packages/uni-shared/src/constants.ts b/packages/uni-shared/src/constants.ts index ce380f39e..83faa5ca0 100644 --- a/packages/uni-shared/src/constants.ts +++ b/packages/uni-shared/src/constants.ts @@ -50,6 +50,8 @@ export const ON_UNHANDLE_REJECTION = 'onUnhandledRejection' export const ON_LOAD = 'onLoad' export const ON_READY = 'onReady' export const ON_UNLOAD = 'onUnload' +// 百度特有 +export const ON_INIT = 'onInit' export const ON_RESIZE = 'onResize' export const ON_BACK_PRESS = 'onBackPress' -- GitLab