Skip to content
## priceFormatToParts(amount : string, decimals : number, thousandsSeparator : string, currencySymbol : string) : object[] > 金额格式化函数,将数字字符串拆分为货币格式的部件数组。

支持平台 ​

安卓iosweb微信小程序
√√√√

参数 ​

  • amount: string - 要格式化的金额。
  • decimals: number - 小数点后保留的位数。
  • thousandsSeparator: string - 千位分隔符。
  • currencySymbol: string - 货币符号。

返回值 ​

  • object[]: 返回格式化后的部件数组,每个部件包含 value 字段。

示例 ​

javascript
import { priceFormatToParts } from '@/uni_modules/tui-common';
const formattedPrice = priceFormatToParts('123456.78', 2, ',', '¥').map(item => item.value).join('');
console.log(formattedPrice); // 输出: "¥123,456.78"

upperMoney(amount : string) : string ​

将数字金额转换为中文大写金额。

支持平台 ​

安卓iosweb微信小程序
√√√√

参数 ​

  • amount: string - 要转换的金额。

返回值 ​

  • string: 返回中文大写金额字符串。

示例 ​

javascript
import { upperMoney } from '@/uni_modules/tui-common';
const upperMoneyResult = upperMoney('123456.78');
console.log(upperMoneyResult); // 输出: "壹佰贰拾叁万肆仟伍佰陆拾柒元捌角"

fmtMoney(amount : string, uppercase : boolean) : string ​

金额格式化,支持千分位分隔和大写转换。

支持平台 ​

安卓iosweb微信小程序
√√√√

参数 ​

  • amount: string - 要格式化的金额。
  • uppercase: boolean - 是否转换为中文大写。

返回值 ​

  • string: 返回格式化后的金额字符串。

示例 ​

javascript
import { fmtMoney } from '@/uni_modules/tui-common';
fmtMoney('123456.78', false) // 输出: "123,456.78"
fmtMoney('123456.78', true) // 输出: "壹拾贰万叁仟肆佰伍拾陆元柒角捌分"

sensitiveWordFilter(text : string, replaceChar : string) : string ​

敏感词过滤,将指定字符替换为掩码。

支持平台 ​

安卓iosweb微信小程序
√√√√

参数 ​

  • text: string - 待过滤的文本。
  • replaceChar: string - 替换字符。

返回值 ​

  • string: 返回过滤后的字符串。

示例 ​

javascript
import { sensitiveWordFilter } from '@/uni_modules/tui-common';
sensitiveWordFilter('张三丰', '*') // 输出: "***"