From a6fc73652bbd9472d75194db9f92e28b42d16ca2 Mon Sep 17 00:00:00 2001 From: cos2004 Date: Fri, 17 Aug 2018 16:05:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(view):=20=E4=BF=AE=E5=A4=8Dbadge=E4=BC=A0?= =?UTF-8?q?=E5=8F=82=E4=B8=BA=E7=A9=BA=E5=AD=97=E7=AC=A6=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/badge/index.js | 5 ++++- src/pages/view/badge/index.js | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/badge/index.js b/src/components/badge/index.js index 98f70ce72..110dbccd9 100644 --- a/src/components/badge/index.js +++ b/src/components/badge/index.js @@ -12,6 +12,7 @@ export default class AtBadge extends Taro.Component { } formatValue (value, maxValue) { + if (value === '' || value === null) return '' const numValue = +value if (loadash.isNaN(numValue)) { return value @@ -27,10 +28,12 @@ export default class AtBadge extends Taro.Component { } = this.props const rootClassName = ['at-badge'] + const val = this.formatValue(value, maxValue) + return ( {this.props.children} - {dot ? : {this.formatValue(value, maxValue)}} + {dot ? : val !== '' && {val}} ) } diff --git a/src/pages/view/badge/index.js b/src/pages/view/badge/index.js index 56af7046d..9fbe836ac 100644 --- a/src/pages/view/badge/index.js +++ b/src/pages/view/badge/index.js @@ -18,8 +18,9 @@ export default class BadgePage extends Taro.Component { } } - + /** eslint-disable */ render () { + const dot = '···' return ( {/* S Header */} @@ -91,12 +92,12 @@ export default class BadgePage extends Taro.Component { - + 按钮 - + 按钮