From b6e2c6ed88296a82bc7334470d02fd43552f1e83 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 19 Nov 2021 11:23:15 +0800 Subject: [PATCH] =?UTF-8?q?buttonGroup=E7=9A=84layouts=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=B8=8D=E7=94=A8=E4=BC=A0=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/combination/group.button.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index 622ede324..9f392411a 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -30,7 +30,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { }); this.behaviors = behaviors; this.populate(o.items); - if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){ + if (BI.isKey(o.value) || BI.isNotEmptyArray(o.value)) { this.setValue(o.value); } }, @@ -77,11 +77,12 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { _packageBtns: function (btns) { var o = this.options; - for (var i = o.layouts.length - 1; i > 0; i--) { + var layouts = BI.isArray(o.layouts) ? o.layouts : [o.layouts]; + for (var i = layouts.length - 1; i > 0; i--) { btns = BI.map(btns, function (k, it) { - return BI.extend({}, o.layouts[i], { + return BI.extend({}, layouts[i], { items: [ - BI.extend({}, o.layouts[i].el, { + BI.extend({}, layouts[i].el, { el: it }) ] @@ -108,7 +109,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { }, _packageLayout: function (items) { - var o = this.options, layout = BI.deepClone(o.layouts[0]); + var o = this.options, layout = BI.deepClone(BI.isArray(o.layouts) ? o.layouts[0] : o.layouts); var lay = BI.formatEL(layout).el; while (lay && lay.items && !BI.isEmpty(lay.items)) { @@ -121,7 +122,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { // 如果是一个简单的layout _isSimpleLayout: function () { var o = this.options; - return o.layouts.length === 1 && !BI.isArray(o.items[0]); + return BI.isArray(o.layouts) ? (o.layouts.length === 1 && !BI.isArray(o.items[0])) : true; }, doBehavior: function () {