前端js,ts小写数字转大写 电脑版发表于:2024/8/17 10:50 ### 简单的处理就是用一个键值对来匹配 写好对应的键值对: ``` const state = reactive({ smallBigDic: { 1: "一", 2: "二", 3: "三", 4: "四", 5: "五", 6: "六", 7: "七", 8: "八", 9: "九", 10: "十", 11: "十一", 12: "十二", } }) ``` 写好转化方法: ``` const methods = { numberSmallToBig: function (_num) { let big = state.smallBigDic[_num] if (big) { return big } else { return _num } } } ``` 页面上使用: ``` methods.numberSmallToBig(chapterItem.chapterOrder) ```