Is there a functionality in JavaScript to convert values into specific locale formats?(JavaScript 中是否有将值转换为特定语言环境格式的功能?)
问题描述
是否有 JavaScript 的内置函数可以将字符串转换为特定的语言环境(在我的例子中是欧元)?
Is there a built in function of JavaScript to convert a string into a particular locale (Euro in my case)?
例如50.00
应转换为 50,00 €
.
推荐答案
50.00
是一个无单位值.您可以做的最好的是将 50.00
转换为 50,00
,然后自己附加 €
.因此,只需使用 Number.toLocaleString()
.
50.00
is a unit-less value. The best you can do is convert 50.00
to 50,00
and then append the €
yourself. Therefore, just use Number.toLocaleString()
.
var i = 50.00;
alert(i.toLocaleString() + ' €'); // alerts '50.00 €' or '50,00 €'
演示 →
- 如何在 JavaScript 中将数字格式化为货币?(最大的;约 7 万次观看)
- 转换为货币格式
- 使用javascript格式化货币
- 如何在javascript中打印货币格式
- JavaScript:格式数字/与 .NET 的 String.Format() 等文化相关的货币?(如果您使用的是 ASP.NET,可能很有用)
- 将数字格式化为价格
- How can I format numbers as money in JavaScript? (the big one; ~70k views)
- Convert to currency format
- Format currency using javascript
- how do i print currency format in javascript
- JavaScript: Format number/currency w/regards to culture like .NET's String.Format()? (possibly useful, if you're using ASP.NET)
- format number to price
这篇关于JavaScript 中是否有将值转换为特定语言环境格式的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:JavaScript 中是否有将值转换为特定语言环境格式的功能?


基础教程推荐
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01