toLocaleString()在所有浏览器中都不支持? [英] toLocaleString() not supported in all browsers?
本文介绍了toLocaleString()在所有浏览器中都不支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个简单的功能:
Chrome,Firefox,IE:
Chrome, Firefox, IE:
Number(1000000).toLocaleString()
"1 000 000" // in french system, the space is the separator instead of the comma
Opera,Maxthon:
Opera, Maxthon:
Number(1000000).toLocaleString()
"1000000"
为什么Opera和Maxthon不能格式化?他们支持这种方法,但没有以正确的方式执行它?
why Opera and Maxthon cant format it? they support this method but dont execute it in the right way?
是否有任何 toLocaleString()
替换? / p>
is there any toLocaleString()
replacement?
推荐答案
The language spec leaves the definition very open-ended:
15.7.4.3
数字。 prototype.toLocaleString()
生成一个字符串值,表示根据主机环境当前语言环境的约定格式化的Number值。 这个函数是依赖于实现的,并且允许但不鼓励它返回与toString相同的东西。
允许不同的浏览器以不同的方式实现它,并且可以根据用户选择的区域设置来实现它。
Different browsers are allowed to implement it differently, and can implement it differently based on the locale chosen by the user.
这篇关于toLocaleString()在所有浏览器中都不支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文