提交 af9edeeb 编写于 作者: D DCloud_LXH

chore: mp-toutiao runtime

上级 723195de
...@@ -1087,14 +1087,16 @@ function initTriggerEvent (mpInstance) { ...@@ -1087,14 +1087,16 @@ function initTriggerEvent (mpInstance) {
}; };
} }
function initHook (name, options) { function initHook (name, options, isComponent) {
const oldHook = options.lifetimes[name]; // fix by Lxh 字节自定义组件Component构造器文档上写有created,但是实测只触发了lifetimes上的created
isComponent && (options = options.lifetimes)
const oldHook = options[name];
if (!oldHook) { if (!oldHook) {
options.lifetimes[name] = function () { options[name] = function () {
initTriggerEvent(this); initTriggerEvent(this);
}; };
} else { } else {
options.lifetimes[name] = function (...args) { options[name] = function (...args) {
initTriggerEvent(this); initTriggerEvent(this);
return oldHook.apply(this, args) return oldHook.apply(this, args)
}; };
...@@ -1109,7 +1111,7 @@ if (!MPPage.__$wrappered) { ...@@ -1109,7 +1111,7 @@ if (!MPPage.__$wrappered) {
Page.after = MPPage.after; Page.after = MPPage.after;
Component = function (options = {}) { Component = function (options = {}) {
initHook('created', options); initHook('created', options, true);
return MPComponent(options) return MPComponent(options)
}; };
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册