From 5dd22609b56e171e9595a40a8f5d89b4fad7c629 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 17 Oct 2022 14:58:53 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20listeners=E6=94=AF=E6=8C=81=E4=BC=A0?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/5.inject.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/core/5.inject.js b/src/core/5.inject.js index 0554740f7..5e2cb0a72 100644 --- a/src/core/5.inject.js +++ b/src/core/5.inject.js @@ -449,7 +449,7 @@ } else if (item.el && (item.el.type || options.type)) { el = BI.extend({}, options, item.el); } - + if (el) { var elType = (el.type && el.type.xtype) || el.type; runConfigFunction(elType); @@ -471,12 +471,18 @@ var wType = (w.type && w.type.xtype) || w.type; if (wType === elType) { if (BI.Plugin.hasObject(elType)) { - w.listeners = (w.listeners || []).concat([{ - eventName: BI.Events.MOUNT, - action: function () { + if (!w.listeners || BI.isArray(w.listeners)) { + w.listeners = (w.listeners || []).concat([{ + eventName: BI.Events.MOUNT, + action: function () { + BI.Plugin.getObject(elType, this); + } + }]); + } else { + w.listeners[BI.Events.MOUNT] = function () { BI.Plugin.getObject(elType, this); } - }]); + } } return createWidget(w, context, lazy); }