diff --git a/src/util/dispatcher/regularModule.js b/src/util/dispatcher/regularModule.js index 19555d07..f07ae304 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,8 @@ 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; this._$innerModule.__onShow(_options); this._$innerModule.$update(); } @@ -138,6 +142,7 @@ NEJ.define([ */ _pro.__destroy = function(){ this.__body = _t._$getNodeTemplate(this.__nodeKey); + this._$innerModule.$parentModule=undefined; this._$innerModule.destroy(); delete this.__nodeKey; this.__super();