我有这个简单的功能:
Chrome,Firefox,IE:
Number(1000000).toLocaleString()
"1 000 000" // in french system, the space is the separator instead of the comma
Run Code Online (Sandbox Code Playgroud)
Opera,Maxthon:
Number(1000000).toLocaleString()
"1000000"
Run Code Online (Sandbox Code Playgroud)
为什么Opera和Maxthon无法格式化呢?他们支持这种方法,但不以正确的方式执行它?
有没有toLocaleString()替代品?
我需要以类似的格式显示价格
7
70
700
700 000
70 000
700 000
7 000 000 etc
Run Code Online (Sandbox Code Playgroud)
问题是我从 json 文件收到价格,所以它总是一个字符串。
我想要的是通过 RegEx 将该价格字符串转换为所需的格式。
7000000 = 0000007000 000 77 000 000json数据是否可能,也许有更正确的方法?没有找到任何工作示例。