From e560513780fbd496b30ac7a2e836025ceea06eea Mon Sep 17 00:00:00 2001 From: AlfredMou Date: Wed, 11 Jan 2017 17:25:11 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=88=B6=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=B8=8E=E5=AD=90=E7=BB=84=E4=BB=B6=E7=9A=84=E8=81=94?= =?UTF-8?q?=E7=BB=93=EF=BC=8C=E4=BB=A5=E8=A7=A3=E5=86=B3regular=E7=88=B6?= =?UTF-8?q?=E5=AD=90=E6=A8=A1=E5=9D=97=E7=BB=84=E4=BB=B6=E4=B9=8B=E9=97=B4?= =?UTF-8?q?=E7=9A=84=E9=80=9A=E4=BF=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/dispatcher/regularModule.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/util/dispatcher/regularModule.js b/src/util/dispatcher/regularModule.js index 19555d07..b4f1fda7 100644 --- a/src/util/dispatcher/regularModule.js +++ b/src/util/dispatcher/regularModule.js @@ -30,6 +30,8 @@ NEJ.define([ _pro.__build = function(){ this._$innerModule = new this._$$InnerModule().$inject(this.__body); this.__export.parent = this._$innerModule.$refs.view; + //通过_export将父组件传递给子组件 + this.__export.parentMoudle = this._$innerModule; this._$innerModule.__doSendMessage = this.__doSendMessage._$bind(this); } @@ -64,6 +66,11 @@ NEJ.define([ if(this._$innerModule.__onShow){ this._$innerModule.data.$param = _options.param; this._$innerModule.data.$params = _options.href.split('?')[1]; + //将通过__export传递过来的parent赋值给当前组价,并将parent的child设置成当前组件 + this._$innerModule.$parentModule=_options.data.parentModule; + if(!!this._$innerModule.$parentModule){ + this._$innerModule.$parentModule.$childModule=this._$innerModule; + } this._$innerModule.__onShow(_options); this._$innerModule.$update(); } @@ -138,6 +145,8 @@ NEJ.define([ */ _pro.__destroy = function(){ this.__body = _t._$getNodeTemplate(this.__nodeKey); + this._$innerModule.$parentModule=undefined; + this._$innerModule.$childModule=undefined; this._$innerModule.destroy(); delete this.__nodeKey; this.__super(); From 2ad5845fcf6e0412f9ee289844de42cb5ee27761 Mon Sep 17 00:00:00 2001 From: AlfredMou Date: Thu, 12 Jan 2017 09:50:43 +0800 Subject: [PATCH 2/2] remove $childMoodule property --- src/util/dispatcher/regularModule.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/util/dispatcher/regularModule.js b/src/util/dispatcher/regularModule.js index b4f1fda7..f07ae304 100644 --- a/src/util/dispatcher/regularModule.js +++ b/src/util/dispatcher/regularModule.js @@ -68,9 +68,6 @@ NEJ.define([ this._$innerModule.data.$params = _options.href.split('?')[1]; //将通过__export传递过来的parent赋值给当前组价,并将parent的child设置成当前组件 this._$innerModule.$parentModule=_options.data.parentModule; - if(!!this._$innerModule.$parentModule){ - this._$innerModule.$parentModule.$childModule=this._$innerModule; - } this._$innerModule.__onShow(_options); this._$innerModule.$update(); } @@ -146,7 +143,6 @@ NEJ.define([ _pro.__destroy = function(){ this.__body = _t._$getNodeTemplate(this.__nodeKey); this._$innerModule.$parentModule=undefined; - this._$innerModule.$childModule=undefined; this._$innerModule.destroy(); delete this.__nodeKey; this.__super();