数据处理如何保留两位小数?

小程序 文章 2021-12-09 18:00 470 0 全屏看文

AI助手支持GPT4.0

数据处理如何保留两位小数?How to keep two decimal places in data processing?

数据处理如何保留两位小数?

如图所示,进行数学运算generalCfg.baseProp[0]/100 + [general.level - 1* generalCfg.lvupAtt/100

小程序显示结果为206.17000000000002,只想保留到两位小数点206.17,求教大神怎么处理

As shown in the figure, perform the mathematical operation generalcfg baseProp[0]/100 + [general.level - 1] * generalCfg. Lvupatt / 100 applet displays the result of 206.17000000000002. I just want to keep it to two decimal places 206.17. Ask the great God how to deal with it

回答:

那座桥不该有灯:

编译错误

中式小面包:
{{(generalCfg.baseProp[0]/100 + [general.level - 1] * generalCfg.lvupAtt/100).toFixed(2)}}
那座桥不该有灯:编译错误
中式小面包:那就只能写在js里
凌晨丶傍晚:
toFixed(2)?


那座桥不该有灯:请问一下totixed在哪儿加,JS还是wxml,在哪个位置加,可以给出具体代码吗
凌晨丶傍晚:加在js里
凌晨丶傍晚:你在js里计算完在赋值就行

-EOF-

AI助手支持GPT4.0