【发布时间】:2021-12-19 21:01:34
【问题描述】:
使用toString函数后,我得到电子商务网页购物车代码中的total_amount,但是当我将14.82字符串转换为int数字时,小数点消失了。
<script>
var total_amount_string = <?=json_encode($cart['total_pvp'])?>;//-> 14,82
var total_amount_int = parseInt(total_amount_string).toFixed(2); //-> 14.00(here is the error)
console.log(total_amount_string) //-> 14,82
console.log(total_amount_int) //-> 14.00
</script>
怎么了?
【问题讨论】:
-
是因为
14,82中的,...期望值是多少...
标签: javascript