Browse Source

整理代码

es6
guy 3 years ago
parent
commit
584a0b2c1c
  1. 61
      examples/dev.html
  2. 2
      src/core/wrapper/layout.js

61
examples/dev.html

@ -20,34 +20,53 @@
} }
}, },
setup: function () { setup: function () {
var layout; var list, count = 0;
return function () { return function () {
return { return {
type: "bi.left", type: "bi.vertical",
items: [{ items: [{
type: "bi.button", type: "bi.virtual_group",
text: "点击", height: 100,
handler: function () { ref: function (_ref) {
layout.populate([{ list = _ref;
type: "bi.label", },
key: "1", items: BI.range(10).map(function (item, i) {
text: 1 var r = {
}, {
type: "bi.label", type: "bi.label",
key: "123", text: item,
text: "start" // 指定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", type: "bi.button",
lgap: 10, text: "点击删除第一个元素",
items: [{ handler: function () {
count++;
list.populate(BI.range(10 - count).map(function (i) {
var r = {
type: "bi.label", type: "bi.label",
key: "123", text: i + count,
text: "start" key: i + count,
}], cls: "bi-border"
ref: function (_ref) { };
layout = _ref; if (i + count === 9) {
r.width = "fill";
r.key = "唯一的标识";
}
return r;
}));
} }
}] }]
}; };

2
src/core/wrapper/layout.js

@ -551,9 +551,11 @@ BI.Layout = BI.inherit(BI.Widget, {
c.destroy(); c.destroy();
}); });
this._children = {}; this._children = {};
this._isMounted = false;
} }
this.options.items = opt.items; this.options.items = opt.items;
this.stroke(opt.items); this.stroke(opt.items);
this._mount();
}, },
update: function (opt) { update: function (opt) {

Loading…
Cancel
Save