diff --git a/packages/uni-mp-core/src/runtime/app.ts b/packages/uni-mp-core/src/runtime/app.ts index 47fefa7648478acee99918c22cdade5259f82792..f9976b6de8d9a6e832399f1610cb068979536555 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 ce380f39e3d82ff440b0bf197d22d040c88397d2..83faa5ca0b31f8160f8a2514cab44d577d42bd26 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'