From ebfe202efbc1781d9d2cd3986f6c97788a04cc3e Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 20 Nov 2020 19:46:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E7=BA=AF=E6=96=87=E6=9C=AC=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/text.pure.js | 43 ++++++++++++++++++++++++++++++++++++ src/core/widget.js | 5 ++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/base/single/text.pure.js diff --git a/src/base/single/text.pure.js b/src/base/single/text.pure.js new file mode 100644 index 000000000..0a86e73eb --- /dev/null +++ b/src/base/single/text.pure.js @@ -0,0 +1,43 @@ +/** + * 没有html标签的纯文本 + */ +!(function () { + BI.PureText = BI.inherit(BI.Widget, { + + props: { + tagName: null + }, + + render: function () { + var self = this, o = this.options; + var text = this._getShowText(); + if (BI.isKey(text)) { + this.setText(text); + } else if (BI.isKey(o.value)) { + this.setText(o.value); + } + }, + + _getShowText: function () { + var o = this.options; + var text = BI.isFunction(o.text) ? o.text() : o.text; + text = BI.isKey(text) ? text : o.value; + if (!BI.isKey(text)) { + return ""; + } + return BI.Text.formatText(text + ""); + }, + + setValue: function (value) { + this.options.value = value; + this.setText(value); + }, + + setText: function (text) { + this.options.text = BI.isNotNull(text) ? text : ""; + this.text.element.__textKeywordMarked__(this._getShowText()); + } + }); + BI.shortcut("bi.pure_text", BI.PureText); +}()); + diff --git a/src/core/widget.js b/src/core/widget.js index c5aeca499..6d8cb3929 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -610,7 +610,10 @@ if (o.element) { return BI.$(o.element); } - return BI.$(document.createElement(o.tagName)); + if (o.tagName) { + return BI.$(document.createElement(o.tagName)); + } + return BI.$(document.createDocumentFragment()); } return BI.$(widget); }, From 0a78cb61bfebdfcfe6785dd79753c98b08aab463 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 20 Nov 2020 19:51:00 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BA=AF=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E7=BB=84=E4=BB=B6bi.pure=5Ftext?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + src/base/single/text.pure.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 03776318e..eccb28b37 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-11) +- 增加纯文本组件bi.pure_text - store支持webworker,引入多线程机制 - 修复了Popover小屏幕上看不完整的问题 - 颜色选择器支持输入16进制颜色编号 diff --git a/src/base/single/text.pure.js b/src/base/single/text.pure.js index 0a86e73eb..eb7f6e323 100644 --- a/src/base/single/text.pure.js +++ b/src/base/single/text.pure.js @@ -35,7 +35,7 @@ setText: function (text) { this.options.text = BI.isNotNull(text) ? text : ""; - this.text.element.__textKeywordMarked__(this._getShowText()); + this.element.__textKeywordMarked__(this._getShowText()); } }); BI.shortcut("bi.pure_text", BI.PureText);