简体   繁体   English

在 vue.js - vue-i18n 中使用 i18n(区域设置)的值四舍五入为 3 个十进制值

[英]rounding off to 3 decimal values for the value that uses i18n (regional setting) in vue.js - vue-i18n

I have a method to return the result value,我有一个返回结果值的方法,

---------
        const values = 123.10000;
        const result = i18n.n(values, 'number');
        return result;
--------

In the above,I need to round off the result to 3 decimal point, I tired tofixed, rounD off method but the zeros are not be included in it.在上面,我需要将结果四舍五入到小数点后 3 位,我厌倦了固定,四舍五入的方法,但其中不包含零。

expected output result is 123.100.预期 output 结果为123.100.

but i am getting 123.1 , how should i add the decimal round off method to 3 decimal digits with the values having zeros但我得到123.1 ,我应该如何将十进制舍入方法添加到 3 个十进制数字,值为零

Try use this.试试用这个。

The toFixed() method formats a number using fixed-point notation. toFixed() 方法使用定点表示法格式化数字。 ref 参考

const values = 123.1;
const result = values.toFixed(3);
console.log(result);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM