Commit bf833b03 authored by ddcat1115's avatar ddcat1115

fix ChartCard total issue close #1110

parent aa675880
...@@ -4,6 +4,21 @@ import classNames from 'classnames'; ...@@ -4,6 +4,21 @@ import classNames from 'classnames';
import styles from './index.less'; import styles from './index.less';
const renderTotal = (total) => {
let totalDom;
switch (typeof total) {
case undefined:
totalDom = null;
break;
case 'string':
totalDom = <div className={styles.total} dangerouslySetInnerHTML={{ __html: total }} />;
break;
default:
totalDom = <div className={styles.total}>{total}</div>;
}
return totalDom;
};
const ChartCard = ({ const ChartCard = ({
loading = false, contentHeight, title, avatar, action, total, footer, children, ...rest loading = false, contentHeight, title, avatar, action, total, footer, children, ...rest
}) => { }) => {
...@@ -22,10 +37,7 @@ const ChartCard = ({ ...@@ -22,10 +37,7 @@ const ChartCard = ({
<span className={styles.title}>{title}</span> <span className={styles.title}>{title}</span>
<span className={styles.action}>{action}</span> <span className={styles.action}>{action}</span>
</div> </div>
{ {renderTotal(total)}
// eslint-disable-next-line
(total !== undefined) && (<div className={styles.total} dangerouslySetInnerHTML={{ __html: total }} />)
}
</div> </div>
</div> </div>
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment