From 584a0b2c1c768dcb5ceab2924a4ef08c42ca7e1f Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 24 Aug 2021 13:56:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/dev.html | 65 ++++++++++++++++++++++++-------------- src/core/wrapper/layout.js | 2 ++ 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/examples/dev.html b/examples/dev.html index 7a11279b2..975879916 100644 --- a/examples/dev.html +++ b/examples/dev.html @@ -20,34 +20,53 @@ } }, setup: function () { - var layout; + var list, count = 0; return function () { return { - type: "bi.left", + type: "bi.vertical", items: [{ - type: "bi.button", - text: "点击", - handler: function () { - layout.populate([{ - type: "bi.label", - key: "1", - text: 1 - }, { + type: "bi.virtual_group", + height: 100, + ref: function (_ref) { + list = _ref; + }, + items: BI.range(10).map(function (item, i) { + var r = { type: "bi.label", - key: "123", - text: "start" - }]) - } + text: item, + // 指定key后,会根据key值进行前后两次数据对比,否则会根据数组索引进行数据对比 + key: item, + cls: "bi-border" + }; + if (i === 9) { + r.width = "fill"; + r.key = "唯一的标识"; + } + return r; + }), + layouts: [{ + type: "bi.inline", + tgap: 10, + lgap: 10 + }] }, { - type: "bi.left", - lgap: 10, - items: [{ - type: "bi.label", - key: "123", - text: "start" - }], - ref: function (_ref) { - layout = _ref; + type: "bi.button", + text: "点击删除第一个元素", + handler: function () { + count++; + list.populate(BI.range(10 - count).map(function (i) { + var r = { + type: "bi.label", + text: i + count, + key: i + count, + cls: "bi-border" + }; + if (i + count === 9) { + r.width = "fill"; + r.key = "唯一的标识"; + } + return r; + })); } }] }; diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index d6634e328..0bde292a7 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -551,9 +551,11 @@ BI.Layout = BI.inherit(BI.Widget, { c.destroy(); }); this._children = {}; + this._isMounted = false; } this.options.items = opt.items; this.stroke(opt.items); + this._mount(); }, update: function (opt) {