我有这个简单的功能:
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,傲游:
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() 替换?
语言规范 定义非常开放:
生成一个字符串值,该值表示根据宿主环境当前语言环境的约定格式化的数字值.此函数依赖于实现,允许但不鼓励它返回与 toString 相同的内容.
15.7.4.3
Number.prototype.toLocaleString()Produces a String value that represents this Number value formatted according to the conventions of the host environment’s current locale. This function is implementation-dependent, and it is permissible, but not encouraged, for it to return the same thing as toString.
允许不同的浏览器以不同的方式实现它,并且可以根据用户选择的语言环境以不同的方式实现它.
Different browsers are allowed to implement it differently, and can implement it differently based on the locale chosen by the user.
这篇关于并非所有浏览器都支持 toLocaleString()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Browserify,Babel 6,Gulp - 传播运算符上的意外令牌Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 传播运算符上的意外令牌)
是否可以将标志传递给 Gulp 以使其以不同的方式Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以将标志传递给 Gulp 以使其以不同的方式运行任务
为什么我们需要在全局和本地安装 gulp?Why do we need to install gulp globally and locally?(为什么我们需要在全局和本地安装 gulp?)
如何一个接一个地依次运行 Gulp 任务How to run Gulp tasks sequentially one after the other(如何一个接一个地依次运行 Gulp 任务)
打开 Javascript 文件时 Visual Studio 2015 崩溃Visual Studio 2015 crashes when opening Javascript files(打开 Javascript 文件时 Visual Studio 2015 崩溃)
检测 FLASH 插件崩溃Detect FLASH plugin crashes(检测 FLASH 插件崩溃)