添加bar组件

This commit is contained in:
2025-11-05 17:34:23 +08:00
parent 7314f23529
commit 3cb63ffca7
223 changed files with 23185 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
// @ts-nocheck
/**
* 将字符串转换为数字
* @param val 要转换的字符串
* @returns 转换后的数字或原始字符串
*/
// #ifdef UNI-APP-X && APP
// function toNumber(val: string): number
// function toNumber(val: string): string
function toNumber(val: string): number|null {
const n = parseFloat(val); // 使用 parseFloat 函数将字符串转换为浮点数
return isNaN(n) ? null : n; // 使用 isNaN 函数判断是否为非数字,返回转换后的数字或原始字符串
}
export {toNumber}
// #endif
// #ifndef UNI-APP-X && APP
export function toNumber(val: string): number | string {
const n = parseFloat(val); // 使用 parseFloat 函数将字符串转换为浮点数
return isNaN(n) ? val : n; // 使用 isNaN 函数判断是否为非数字,返回转换后的数字或原始字符串
}
// #endif
// 示例
// console.log(toNumber("123")); // 输出: 123
// console.log(toNumber("3.14")); // 输出: 3.14
// console.log(toNumber("hello")); // 输出: "hello"