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 中是否有将值转换为特定语言环境格式的功能?
基础教程推荐
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
