Internationalization(Number formatting quot;num.toLocaleString()quot;) not working for chrome(国际化(数字格式“num.toLocaleString())不适用于 chrome)
问题描述
我想在 Javascript 中进行数字格式化.. 我使用以下方法num.toLocaleString() 适用于 Firefox、IE 但不适用于 Google Chrome..我需要添加它才能在 chrome 浏览器中工作.
i want do number formatting in Javascript.. and i use the following method num.toLocaleString() which will work for Firefox, IE but doesnt work for Google Chrome.. Wat i need to add for it work in chrome browser.
推荐答案
toLocaleString()
方法根据定义是依赖于实现的:它使用实现语言环境,例如浏览器语言环境.因此,如果我查看您使用该方法的页面,我会看到根据芬兰语或英语语言环境设置格式的数字,具体取决于我使用的浏览器.
The toLocaleString()
method is by definition implementation-dependent: it uses the implementation locale, such as browser locale. So if I were looking at your page that uses the method, I would see numbers formatted according to Finnish or English locale, depending on which browser I’m using.
您想要的是按页面的语言环境进行本地化,为此您需要其他东西.在简单的情况下,您可能会自己编写代码,但数字格式通常很复杂,因此使用库是合理的,例如 全球化.查看一个简单的 demo 的精简源代码.在 Globalize 中,您在指定区域设置时使用 标准语言代码.
What you want is localization by the locale of the page, and for this you need something else. In simple cases you might code it yourself, but number formatting is in general complicated, making it reasonable to use a library, such as Globalize. Check out the compact source of a simple demo. In Globalize, you use standard language codes when specifying the locale.
这篇关于国际化(数字格式“num.toLocaleString()")不适用于 chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:国际化(数字格式“num.toLocaleString()")不适用于 chrome


基础教程推荐
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 直接将值设置为滑块 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01