[Vuejs]-In Vue.js project, I can not get the correct multiplication result

1👍

alternatively, use toFixed

<span>{{ (discount_point_total*100).toFixed(2) }}%</span>

1👍

The float point number precision lost, you can use this method to avoid the issue:

<span>{{ Math.round(discount_point_total * 100 * 100) / 100 }}%</span>

0👍

Use toFixed
{{ (0.022*100).toFixed(2) }}%

Note that the return value of this method is a string. Remember parseFloat when you use it. You need to know more about the foundation of ECMA Script.

Leave a comment