nutui
nutui copied to clipboard
[suggest] Price组件 formatToHump函数优化
当前price组件的formatToHump函数如下
const formatToHump = (price: string | number) => {
if (Number(price) == 0) {
return 0;
}
if (checkPoint(price)) {
price = Number(price).toFixed(props.decimalDigits);
return renderPrice(price.split('.'));
} else {
return renderPrice(price.toString());
}
};
其中
price = Number(price).toFixed(props.decimalDigits);
这里没有必要格式price,因为在formatDecimal函数中也会对做price进行toFixed处理,前面这里显得有点重复处理了
你建议我们做什么?
现在...
formatToHump 函数中不对price数据进行toFixed处理,仅转换为数字,然后数据类型转换为字符串,在给renderPrice处理,具体修改后代码如下
// price = Number(price).toFixed(props.decimalDigits);
price = Number(price)
return renderPrice((price + '').split('.'));
其它
无
可以直接提PR @LastStartDust
可以直接提PR @LastStartDust
已经提啦