diff --git a/app/pages/home/components/ItemList/index.vue b/app/pages/home/components/ItemList/index.vue index aeb1145..81f6b29 100644 --- a/app/pages/home/components/ItemList/index.vue +++ b/app/pages/home/components/ItemList/index.vue @@ -40,6 +40,26 @@ const openShow = async (item) => { localState.value.showDetail = true currentItem.value = item } +/** + * 将数字格式化为"250XX"格式,其中XX是两位数 + * @param {number} num - 要格式化的数字 + * @return {string} - 格式化后的字符串 + */ + function formatNumber(num) { + // 确保输入是有效数字 + if (typeof num !== 'number' && isNaN(Number(num))) { + throw new Error('输入必须是有效数字'); + } + + // 转换为数字类型(以防输入是字符串数字) + const number = Number(num); + + // 数字部分格式化为两位数,不足补0 + const formattedNum = number.toString().padStart(2, '0'); + + // 添加前缀"250"并返回结果 + return `250${formattedNum}`; +}