Javascript将int值格式化为特定样式

问题描述 投票:1回答:1

您好我正在寻找比较cypress中2个值的解决方案。 期望值== 34 000,00,我的价值34000 有没有人知道Intl.NumberFormat或任何其他人将我的价值设定为正确的风格?

javascript typescript cypress
1个回答
0
投票

使用Intl.NumberFormat

var number = 34000;
console.log(new Intl.NumberFormat('pl-PL', { style: 'decimal', minimumFractionDigits: 2 }).format(number));

// Output: "34 000,00"
© www.soinside.com 2019 - 2024. All rights reserved.