From af9edeebb10e2118a403f11e5cc85b31f8685d54 Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Fri, 13 Aug 2021 10:47:59 +0800 Subject: [PATCH] chore: mp-toutiao runtime --- packages/uni-mp-toutiao/dist/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index b9fd8a990..32728fdbf 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -1087,14 +1087,16 @@ function initTriggerEvent (mpInstance) { }; } -function initHook (name, options) { - const oldHook = options.lifetimes[name]; +function initHook (name, options, isComponent) { + // fix by Lxh 字节自定义组件Component构造器文档上写有created,但是实测只触发了lifetimes上的created + isComponent && (options = options.lifetimes) + const oldHook = options[name]; if (!oldHook) { - options.lifetimes[name] = function () { + options[name] = function () { initTriggerEvent(this); }; } else { - options.lifetimes[name] = function (...args) { + options[name] = function (...args) { initTriggerEvent(this); return oldHook.apply(this, args) }; @@ -1109,7 +1111,7 @@ if (!MPPage.__$wrappered) { Page.after = MPPage.after; Component = function (options = {}) { - initHook('created', options); + initHook('created', options, true); return MPComponent(options) }; } -- GitLab