From 6b9fe9288cb5e9ad9330c02cfbf683020d1bfc6d Mon Sep 17 00:00:00 2001 From: imp Date: Tue, 19 Oct 2021 17:48:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20=E5=90=8C?= =?UTF-8?q?=E6=AD=A5hook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/fix/fix.compact.js | 4 +++- src/core/4.widget.js | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dist/fix/fix.compact.js b/dist/fix/fix.compact.js index 8b635c0c1..442535146 100644 --- a/dist/fix/fix.compact.js +++ b/dist/fix/fix.compact.js @@ -152,9 +152,11 @@ if (_global.Fix && this._store) { needPop = true; pushTarget(this.store); - initWatch(this, this.watch); } _render.apply(this, arguments); + if (_global.Fix && this._store) { + initWatch(this, this.watch); + } // try { // _render.apply(this, arguments); // } catch (e) { diff --git a/src/core/4.widget.js b/src/core/4.widget.js index b0d245808..a3ec2c374 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -148,10 +148,12 @@ _render: function () { this.__asking = false; + pushTarget(this); callLifeHook(this, "beforeCreate"); this._initElement(); this._initEffects(); callLifeHook(this, "created"); + popTarget(); this.__async = false; }, @@ -299,6 +301,7 @@ var self = this; var isMounted = this._isMounted; this.__async === true && isMounted && callLifeHook(this, "beforeMount"); + this.__isMounting = true; // if (!this._initVNode()) { var render = BI.isFunction(this.options.render) ? this.options.render : this.render; var els = render && render.call(this); @@ -388,6 +391,7 @@ layer = layer || 0; lifeHook !== false && !this.__async && callLifeHook(this, "beforeMount"); this._isMounted = true; + this.__isMounting = false; for (var key in this._children) { var child = this._children[key]; !self.isEnabled() && child._setEnable(false); @@ -798,6 +802,10 @@ BI.onBeforeMount = function (beforeMount) { if (current) { + if(current.__isMounting){ + beforeMount(); + return; + } if (!current.beforeMount) { current.beforeMount = []; } else if (!BI.isArray(current.beforeMount)) { @@ -808,6 +816,10 @@ }; BI.onMounted = function (mounted) { if (current) { + if(current._isMounted && !this.__async){ + mounted(); + return; + } if (!current.mounted) { current.mounted = []; } else if (!BI.isArray(current.mounted)) {