Browse Source

children的key就用索引替代

es6
guy 4 years ago
parent
commit
703e5b47f7
  1. 6
      src/core/wrapper/layout.js
  2. 2
      src/core/wrapper/layout/layout.card.js

6
src/core/wrapper/layout.js

@ -83,7 +83,7 @@ BI.Layout = BI.inherit(BI.Widget, {
}, },
_getChildName: function (index) { _getChildName: function (index) {
return this.getName() + "_" + index; return "" + index;
}, },
_addElement: function (i, item, context) { _addElement: function (i, item, context) {
@ -94,7 +94,7 @@ BI.Layout = BI.inherit(BI.Widget, {
BI.each(self._children, function (name, child) { BI.each(self._children, function (name, child) {
if (child === w) { if (child === w) {
BI.remove(self._children, child); BI.remove(self._children, child);
self.removeItemAt(name.replace(self.getName() + "_", "") | 0); self.removeItemAt(name | 0);
} }
}); });
}); });
@ -568,7 +568,7 @@ BI.Layout = BI.inherit(BI.Widget, {
if (BI.isWidget(nameOrWidget)) { if (BI.isWidget(nameOrWidget)) {
BI.each(this._children, function (name, child) { BI.each(this._children, function (name, child) {
if (child === nameOrWidget) { if (child === nameOrWidget) {
removeIndex = name.replace(self.getName() + "_", ""); removeIndex = name;
} }
}); });
} else { } else {

2
src/core/wrapper/layout/layout.card.js

@ -196,7 +196,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
if (BI.isWidget(nameOrWidget)) { if (BI.isWidget(nameOrWidget)) {
BI.each(this._children, function (name, child) { BI.each(this._children, function (name, child) {
if (child === nameOrWidget) { if (child === nameOrWidget) {
removeName = name.replace(self.getName() + "_", ""); removeName = name;
} }
}); });
} else { } else {

Loading…
Cancel
Save