我想编写一个格式函数来显示欧元价格,但它会引发错误。怎么了?
\nconst formatVal = val => new Intl.NumberFormat("de-DE", {\n style: "currency",\n currency: "\xe2\x82\xac"\n}).format(val)\n\nformatVal(456)Run Code Online (Sandbox Code Playgroud)\r\n抛出的错误:
\n\n\n未捕获的 RangeError:无效的货币代码:\xc3\xa2\xc2\xac
\n
将 \xe2\x82\xac 更改为 EUR
\nconst formatVal = val => new Intl.NumberFormat("de-DE", {\n style: "currency",\n currency: "EUR"\n}).format(val)\n\nconsole.log(formatVal(456))Run Code Online (Sandbox Code Playgroud)\r\n| 归档时间: |
|
| 查看次数: |
6213 次 |
| 最近记录: |