应用场景:
把1、2、3,转为一、二、三
方法:
retBigSrt(num) {const changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']const unit = ['', '十', '百']num = parseInt(num)const getWan = (temp) => {const strArr = temp.toString().split('').reverse()let newNum = ''for (var i = 0; i < strArr.length; i++) {newNum = (i === 0 && strArr[i] === 0 ? '' : (i > 0 && strArr[i] === 0 && strArr[i - 1] === 0 ? '' : changeNum[strArr[i]] + (strArr[i] === 0 ? unit[0] : unit[i]))) + newNum}return newNum}const overWan = Math.floor(num / 100)let noWan = num % 100if (noWan.toString().length < 2) noWan = '0' + noWanreturn overWan ? getWan(overWan) + '百' + getWan(noWan) : getWan(num)},
使用:
或者在方法中调用此方法