0
Follow
5
View

How to change decimal character (.) to (,)

lucky_xu123 注册会员
2023-01-26 11:32

You have to differentiate between the visual appealing of the number and the value itself. The value must always be formatted as a floating-point number (using .) How you display your currency, depends on the users' locality. I would recommend using the Intl.NumberFormat API (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) or use a currency formatting library like Dinero.js (https://github.com/dinerojs/dinero.js) Of course, you can already do the formatting on the server-side, but I would recommend doing so on the client.

const value = 54.69;

return (
  <>
   {new Intl.NumberFormat('en', { style: 'currency', currency: 'USD' }).format(value)}
  
)

About the Author

Question Info

Publish Time
2023-01-26 11:32
Update Time
2023-01-26 11:32