1 console.log(new Intl.NumberFormat().format(1000)) // 1,000
2 console.log(new Intl.NumberFormat('zh-CN').format(1000)) // 1,000 中文
3 console.log(new Intl.NumberFormat('en-US').format(1000)) // 1,000 英文
4 const formatter = new Intl.NumberFormat('zh-CN', {
5 style: 'unit',
6 unit: 'meter',
7 });
8 const res = formatter.format(8848.86); // 8.848.86米
9 const formatter = new Intl.NumberFormat('en-US', {
10 style: 'unit',
11 unit: 'meter',
12 });
13 const res = formatter.format(8848.86); // 8.848.86m
参考:https://zhuanlan.zhihu.com/p/356991916