From c8c24d14ab5c9e08bd3f2dadaf3fe87784fa28f8 Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 25 Dec 2021 01:17:25 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=96=B0=E5=A2=9EContext=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + src/base/context.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/base/context.js diff --git a/changelog.md b/changelog.md index e9ae90d8a..0defebe19 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2021-12) +- 新增Context组件 - toast支持closable属性,可控制是否显示关闭按钮 - 新增气泡弹框控件 - BI.point支持widget添加埋点 diff --git a/src/base/context.js b/src/base/context.js new file mode 100644 index 000000000..ecaf5febf --- /dev/null +++ b/src/base/context.js @@ -0,0 +1,45 @@ +/** + * 表示当前对象 + * + * Created by GUY on 2015/9/7. + * @class BI.EL + * @extends BI.Widget + */ +BI.Context = BI.inherit(BI.Widget, { + props: { + context: "", + watch: {}, + el: {}, + items: [] + }, + + render: function () { + var self = this, o = this.options; + this.context = BI.createWidget(o.items[0] || o.el, { + element: this + }); + this.context.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + created: function () { + var o = this.options; + if (o.context) { + BI.watch(o.context, o.watch); + } + }, + + setValue: function (v) { + this.context.setValue(v); + }, + + getValue: function () { + return this.context.getValue(); + }, + + populate: function () { + this.context.populate.apply(this, arguments); + } +}); +BI.shortcut("bi.context", BI.Context);