我正在尝试使用 moment JS 格式化货币值的输出,并使用他们网站上的示例'$ 0,0[.]00'并针对英镑进行编辑'\xc2\xa3 0,0[.]00',仅输出值,而不输出英镑符号。
数字不支持美元以外的货币吗?
\n\n我正在使用的代码是:
\n\nnumeral(200).format('\xc2\xa3 0,0[.]00')\nRun Code Online (Sandbox Code Playgroud)\n
在un\xe2\x80\x93minified 代码的第 67 和 68行有:
\n\n// figure out what kind of format we are dealing with\nif (format.indexOf(\'$\') > -1) { // currency!!!!!\nRun Code Online (Sandbox Code Playgroud)\n\n所以是的,“$”似乎是唯一被识别的货币符号。您可以单独添加货币符号,例如:
\n\nvar amount = \'\xc2\xa3\' + numeral(2456.01231).format(\'0,0[.]00\');\n\nconsole.log(amount); // \xc2\xa32,456.01\nRun Code Online (Sandbox Code Playgroud)\n\n或扩展库以处理其他货币符号。
\n\n使用 ISO 符号 GBP 可能会更好,因为它没有歧义。有许多货币使用 \xc2\xa3 符号,就像许多货币使用 $ 一样。
\n| 归档时间: |
|
| 查看次数: |
3245 次 |
| 最近记录: |