From bf833b03604e7db96e85cf007abfd18db569266e Mon Sep 17 00:00:00 2001 From: ddcat1115 Date: Fri, 16 Mar 2018 11:49:01 +0800 Subject: [PATCH] fix ChartCard total issue close #1110 --- src/components/Charts/ChartCard/index.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/components/Charts/ChartCard/index.js b/src/components/Charts/ChartCard/index.js index db2c4623..2fd10e6f 100644 --- a/src/components/Charts/ChartCard/index.js +++ b/src/components/Charts/ChartCard/index.js @@ -4,6 +4,21 @@ import classNames from 'classnames'; import styles from './index.less'; +const renderTotal = (total) => { + let totalDom; + switch (typeof total) { + case undefined: + totalDom = null; + break; + case 'string': + totalDom =
; + break; + default: + totalDom =
{total}
; + } + return totalDom; +}; + const ChartCard = ({ loading = false, contentHeight, title, avatar, action, total, footer, children, ...rest }) => { @@ -22,10 +37,7 @@ const ChartCard = ({ {title} {action}
- { - // eslint-disable-next-line - (total !== undefined) && (
) - } + {renderTotal(total)}
{ -- GitLab