2025-04-18 10:32:59 +08:00

15 lines
585 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export function helloWorld() {
console.log("Hello World!");
}
/**
* 将数字格式化为美式金额表示法
* 将金额格式化为两位小数,需要处理千分位格式
* @param amount - 需要格式化的数字金额
* @returns 返回格式化后的金额字符串保留2位小数
* @example
* formatMoney(1234.5) // 返回 "1,234.50"
* formatMoney(1000000) // 返回 "1,000,000.00"
*/
export function formatMoney(amount: number) {
return new Intl.NumberFormat('en-US', { style: 'decimal', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(amount);
}