cxc-szcx-uniapp/uni_modules/lime-shared/fillZero/index.ts
2024-09-14 10:26:50 +08:00

11 lines
422 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// @ts-nocheck
/**
* 在数字前填充零,返回字符串形式的结果
* @param number 要填充零的数字
* @param length 填充零后的字符串长度默认为2
* @returns 填充零后的字符串
*/
export function fillZero(number: number, length: number = 2): string {
// 将数字转换为字符串,然后使用 padStart 方法填充零到指定长度
return `${number}`.padStart(length, '0');
}