diff --git a/src/core/3.ob.js b/src/core/3.ob.js index 9eab5d35a..2921d5c89 100644 --- a/src/core/3.ob.js +++ b/src/core/3.ob.js @@ -73,10 +73,10 @@ // 获得一个当前对象的引用 _initRef: function () { if (this.options.__ref) { - this.options.__ref.call(this, this); + this.options.__ref.call(this, this.$delegate || this); } if (this.options.ref) { - this.options.ref.call(this, this); + this.options.ref.call(this); } }, diff --git a/src/core/4.widget.js b/src/core/4.widget.js index 2a8f2e02d..02f74a96b 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -52,8 +52,14 @@ _constructed: function () { if (this.setup) { pushTarget(this); - this.service = this.setup(this.options); - this.render = BI.isPlainObject(this.service) ? this.service.render : this.service; + var delegate = this.setup(this.options); + if (BI.isPlainObject(delegate)) { + this.render = delegate.render; + // setup返回一个json,即对外暴露的方法 + this.$delegate = delegate; + } else { + this.render = delegate; + } popTarget(); } },