From b6f291ae780313d4b95f7c21500cc8711fb0cfd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joker=2EWang-=E7=8E=8B=E9=A1=BA?= Date: Wed, 14 Dec 2022 11:40:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9bi.a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/core/abstract/demo.button_group.js | 103 +++++++++++---------- src/base/single/a/a.js | 51 +++++----- 2 files changed, 85 insertions(+), 69 deletions(-) diff --git a/demo/js/core/abstract/demo.button_group.js b/demo/js/core/abstract/demo.button_group.js index 21652ad58..059b97847 100644 --- a/demo/js/core/abstract/demo.button_group.js +++ b/demo/js/core/abstract/demo.button_group.js @@ -7,54 +7,63 @@ Demo.Func = BI.inherit(BI.Widget, { return { type: "bi.vertical", items: [{ - type: "bi.button_group", - ref: function (_ref) { - ref = _ref; + type: "bi.a", + el: { + type: "bi.label", + text: "这就是一个百度超链" }, - chooseType: BI.ButtonGroup.CHOOSE_TYPE_NONE, - layouts: [{ - type: "bi.vertical", - items: [{ - type: "bi.vtape", - height: 200 - }] - }], - items: [{ - el: { - type: "bi.label", - text: "button_group是一类具有相同属性或相似属性的抽象, 本案例实现的是布局的嵌套(vertical布局下内嵌center_adapt布局)" - }, - height: 150 - }, { - el: { - type: "bi.button", - text: "1" - } - }] - }, { - type: "bi.button", - text: "populate", - handler: function () { - ref.populate([{ - el: { - type: "bi.label", - text: "1" - }, - height: 50 - }, { - el: { - type: "bi.button", - text: "2" - }, - height: 50 - }, { - el: { - type: "bi.label", - text: "3" - } - }]); - } - }] + href: "https://www.baidu.com" + }], + // type: "bi.vertical", + // items: [{ + // type: "bi.button_group", + // ref: function (_ref) { + // ref = _ref; + // }, + // chooseType: BI.ButtonGroup.CHOOSE_TYPE_NONE, + // layouts: [{ + // type: "bi.vertical", + // items: [{ + // type: "bi.vtape", + // height: 200 + // }] + // }], + // items: [{ + // el: { + // type: "bi.label", + // text: "button_group是一类具有相同属性或相似属性的抽象, 本案例实现的是布局的嵌套(vertical布局下内嵌center_adapt布局)" + // }, + // height: 150 + // }, { + // el: { + // type: "bi.button", + // text: "1" + // } + // }] + // }, { + // type: "bi.button", + // text: "populate", + // handler: function () { + // ref.populate([{ + // el: { + // type: "bi.label", + // text: "1" + // }, + // height: 50 + // }, { + // el: { + // type: "bi.button", + // text: "2" + // }, + // height: 50 + // }, { + // el: { + // type: "bi.label", + // text: "3" + // } + // }]); + // } + // }] }; } diff --git a/src/base/single/a/a.js b/src/base/single/a/a.js index 9159f0a46..a11e0f91b 100644 --- a/src/base/single/a/a.js +++ b/src/base/single/a/a.js @@ -6,29 +6,36 @@ * @extends BI.Text * @abstract */ -BI.A = BI.inherit(BI.Text, { - _defaultConfig: function () { - var conf = BI.A.superclass._defaultConfig.apply(this, arguments); +import { shortcut } from "../../../core/decorator"; +@shortcut() +export class A extends BI.Text { + static xtype = "bi.a"; + constructor() { + super(); + } + // TODO:这里如何修改有问题 + _defaultConfig() { + var conf = super._defaultConfig(arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-a display-block", + href: "", + target: "_blank", + el: null, + tagName: "a", + }); + } - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-a display-block", - href: "", - target: "_blank", - el: null, - tagName: "a", + render() { + var o = this.options; + super.render(); + this.element.attr({ href: o.href, target: o.target }); + if (o.el) { + BI.createWidget(o.el, { + element: this, }); - }, + } + } - render: function () { - var o = this.options; - BI.A.superclass.render.apply(this, arguments); - this.element.attr({ href: o.href, target: o.target }); - if (o.el) { - BI.createWidget(o.el, { - element: this, - }); - } - }, -}); +} -BI.shortcut("bi.a", BI.A); +BI.extend(BI, { A });