jhzh
2025-04-25 dfa832402406320240380fb5372f4a19ed62b2f7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
export const $USD = "";
export const $USDT = "SAR";
 
export function $toLocaleString(
  number,
  showCurrencySymbol = true, // 是否显示货币符号,默认为 true
  locale = "ar-SA", // 默认使用印度英语的语言环境
  options = {
    // style:可选值为 decimal(小数)、currency(货币)或 percent(百分比);
    // currency:设置为货币样式时使用的符号,支持列表在这里;
    // useGrouping:布尔值,是否显示数字分位。
    style: "currency",
    currency: "SAR",
    minimumFractionDigits: 2 //如果不想要显示末尾的小数「.00」,只要设置一下最小分位 minimumFractionDigits 即可(默认是 2):
  }
) {
  number = number || 0;
  let str = Number(number).toLocaleString(locale, options);
  if (showCurrencySymbol) {
    str = str.replaceAll(" ﷼", "");
  }
  return str;
}