From dc66e666e666db0298be53de7652603dc2c8a7c3 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 12 Oct 2020 15:58:37 +0800 Subject: [PATCH] =?UTF-8?q?context=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/fix/fix.compact.js | 2 +- src/base/collection/collection.js | 8 ++++---- src/base/grid/grid.js | 6 +++--- src/core/shortcut.js | 7 ++++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dist/fix/fix.compact.js b/dist/fix/fix.compact.js index dbf7ae261..f6ec60a72 100644 --- a/dist/fix/fix.compact.js +++ b/dist/fix/fix.compact.js @@ -135,7 +135,7 @@ function createStore () { var needPop = false; if (_global.Fix && this._store) { - var store = findStore(this.options.context || this.options.element); + var store = findStore(this.options.context || this._parent || this.options.element || BI.Widget.context || this._context); if (store) { pushTarget(store); needPop = true; diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index 02cf54e8c..bfe2652f5 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -32,7 +32,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { this._debounceRelease = BI.debounce(function () { self._scrollLock = false; }, 1000 / 60); - this.container = BI.createWidget({ + this.container = BI._lazyCreateWidget({ type: "bi.absolute" }); this.element.scroll(function () { @@ -47,7 +47,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { scrollTop: o.scrollTop }); }); - BI.createWidget({ + BI._lazyCreateWidget({ type: "bi.vertical", element: this, scrollable: o.overflowX === true && o.overflowY === true, @@ -176,7 +176,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { } renderedCells.push(child = this.renderedCells[index]); } else { - child = BI.createWidget(BI.extend({ + child = BI._lazyCreateWidget(BI.extend({ type: "bi.label", width: datum.width, height: datum.height @@ -377,4 +377,4 @@ BI.CollectionView = BI.inherit(BI.Widget, { } }); BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut("bi.collection_view", BI.CollectionView); \ No newline at end of file +BI.shortcut("bi.collection_view", BI.CollectionView); diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index 056983b23..13231e59d 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -35,7 +35,7 @@ BI.GridView = BI.inherit(BI.Widget, { this._debounceRelease = BI.debounce(function () { self._scrollLock = false; }, 1000 / 60); - this.container = BI.createWidget({ + this.container = BI._lazyCreateWidget({ type: "bi.absolute" }); this.element.scroll(function () { @@ -50,7 +50,7 @@ BI.GridView = BI.inherit(BI.Widget, { scrollTop: o.scrollTop }); }); - BI.createWidget({ + BI._lazyCreateWidget({ type: "bi.vertical", element: this, scrollable: o.overflowX === true && o.overflowY === true, @@ -153,7 +153,7 @@ BI.GridView = BI.inherit(BI.Widget, { child = this.renderedCells[index].el; renderedCells.push(this.renderedCells[index]); } else { - child = BI.createWidget(BI.extend({ + child = BI._lazyCreateWidget(BI.extend({ type: "bi.label", width: columnDatum.size, height: rowDatum.size diff --git a/src/core/shortcut.js b/src/core/shortcut.js index b377bac9f..e14646c67 100644 --- a/src/core/shortcut.js +++ b/src/core/shortcut.js @@ -11,7 +11,7 @@ }; // 根据配置属性生成widget - var createWidget = function (config, lazy) { + var createWidget = function (config, context, lazy) { var cls = kv[config.type]; if (!cls) { @@ -19,6 +19,7 @@ } var widget = new cls(); + widget._context = context; BI.Widget.pushContext(widget); widget._initProps(config); widget._initRoot(); @@ -57,7 +58,7 @@ BI.Plugin.getObject(el.type, this); } }]); - return w.type === el.type ? createWidget(w, lazy) : BI.createWidget(BI.extend({}, item, {type: w.type}), options, context, lazy); + return w.type === el.type ? createWidget(w, context, lazy) : BI.createWidget(BI.extend({}, item, {type: w.type}), options, context, lazy); } if (item.el && (item.el.type || options.type)) { el = BI.extend({}, options, item.el); @@ -68,7 +69,7 @@ BI.Plugin.getObject(el.type, this); } }]); - return w.type === el.type ? createWidget(w, lazy) : BI.createWidget(BI.extend({}, item, {type: w.type}), options, context, lazy); + return w.type === el.type ? createWidget(w, context, lazy) : BI.createWidget(BI.extend({}, item, {type: w.type}), options, context, lazy); } if (BI.isWidget(item.el)) { return item.el;