From 4925a60e44cbaab9977c4ad63e0ffbcfe9ce0da4 Mon Sep 17 00:00:00 2001 From: Jackson Date: Wed, 22 Nov 2017 15:04:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20event=E9=97=AE=E9=A2=98=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=20(#917)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: event问题解决 * feat: event问题解决 --- src/mip-showmore/mip-showmore.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/mip-showmore/mip-showmore.js b/src/mip-showmore/mip-showmore.js index 4a299faa2..7397b0452 100755 --- a/src/mip-showmore/mip-showmore.js +++ b/src/mip-showmore/mip-showmore.js @@ -214,7 +214,9 @@ define(function (require) { Showmore.prototype.toggle = function (event) { var me = this; var classList = this.ele.classList; - var clickBtn = matchOriginTarget(this.ele.id.trim(), event.target); + var clickBtn = event && event.target + ? matchOriginTarget(this.ele.id.trim(), event.target) + : null; var opt = {}; opt.aniTime = this.animateTime; if (this.showType === this.heightType[2]) { @@ -291,13 +293,17 @@ define(function (require) { if (!status) { return; } - var closeclass = clickBtn.dataset.closeclass; + var closeclass; + if (clickBtn && clickBtn.dataset && clickBtn.dataset.closeclass) { + closeclass = clickBtn.dataset.closeclass; + } if (status === 'showOpen') { // v1.1.0 显示“展开”按钮 if (clickBtn) { if (closeclass) { clickBtn.classList.remove(closeclass); - } else { + } + else { clickBtn.innerText = clickBtn.dataset.opentext; } } @@ -312,8 +318,9 @@ define(function (require) { // v1.1.0显示“收起”按钮 if (clickBtn) { if (closeclass) { - clickBtn.classList.add(closeclass) - } else { + clickBtn.classList.add(closeclass); + } + else { var opentext = clickBtn.innerText; clickBtn.innerText = clickBtn.dataset.closetext || '收起'; clickBtn.dataset.opentext = opentext;