From e8575cc8e05b46f52f888bd19eafe84c5a973c19 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 2 Mar 2021 23:05:39 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0beforeRender=E7=94=9F?= =?UTF-8?q?=E5=91=BD=E5=91=A8=E6=9C=9F=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/widget.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/core/widget.js b/src/core/widget.js index f43bffce0..cce4c4b3f 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -59,9 +59,11 @@ } }, + // 生命周期函数 beforeInit: null, - // 生命周期函数 + beforeRender: null, + beforeCreate: null, created: null, @@ -94,14 +96,24 @@ }, _initRender: function () { + var self = this; + + function render () { + if (self.options.beforeRender || self.beforeRender) { + (self.options.beforeRender || self.beforeRender).call(this, BI.bind(self._render, this)); + } else { + self._render(); + } + } + if (this.options.beforeInit || this.beforeInit) { this.__asking = true; - (this.options.beforeInit || this.beforeInit).call(this, BI.bind(this._render, this)); + (this.options.beforeInit || this.beforeInit).call(this, render); if (this.__asking === true) { this.__async = true; } } else { - this._render(); + render(); } }, From 58b30fe8eb76f8c7fc21e53c7a11b39529b2b2bc Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 2 Mar 2021 23:06:15 +0800 Subject: [PATCH 2/3] update --- src/core/widget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/widget.js b/src/core/widget.js index cce4c4b3f..d57eef8bc 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -100,7 +100,7 @@ function render () { if (self.options.beforeRender || self.beforeRender) { - (self.options.beforeRender || self.beforeRender).call(this, BI.bind(self._render, this)); + (self.options.beforeRender || self.beforeRender).call(self, BI.bind(self._render, self)); } else { self._render(); } From c1722d189778a27ca539f5eef6f291fe845780ad Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 3 Mar 2021 00:34:34 +0800 Subject: [PATCH 3/3] update --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 6574a00bf..33e3df22f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,7 @@ # 更新日志 2.0(2021-02) - 增加updateModel属性,可以配置自动模式,自动watch属性并响应变化 +- 增加beforeRender生命周期函数 2.0(2021-01) - 修改了日期下拉面板中的当前时间按钮的交互效果