@vhen2023/fs-helper
v0.0.0
Published
| 函数 | 举例 | 描述 | | -------------------- | --------------------------------------------------------- | -----------------------------------
Readme
@vhen/fs-helper
工具类
| 函数 | 举例 | 描述 | | -------------------- | --------------------------------------------------------- | ---------------------------------------------------- | | convertToRMB | convertToRMB(120) | 数字金额转化为大写金额 | | hideMobile | hideMobile('15612345678') | 隐藏手机号 | | toCase | toCase('test',3) | 大小写转化(1-大写,2-小写,3-首字母大写) | | trim | trim(' t e s t ', 4) | 去除空格 (1-所有空格 2-前后空格 3-前空格 4-后空格) | | LoadScript | LoadScript('test.ts', () => {}) | 异步加载 JS | | padZero | padZero(1, 2) | 数字补位 001 | | setObjToUrlParams | setObjToUrlParams('http://www.baidu.com', { a: 1, b: 2 }) | 将对象作为参数添加到 URL | | setUrlParamsToObj | setUrlParamsToObj('http://www.baidu.com?a=1&b=2') | 将 URL 中的参数转为对象 | | onlyDecimalOrInteger | onlyDecimalOrInteger('432.356',true) | 小数或整数(不可以负数) ,第二个参数控制是否四舍五入 | | onlyInteger | onlyInteger('222') | 正整数 | | randomRangeInteger | randomRangeInteger(10,30) | 在某个区间随机一个整数 | | greetings | greetings() | 问候语:早中晚等 | | thousandSeparator | thousandSeparator(1215455.1234, ',') | 千分位分隔符 |
时间类
// 依赖 dayjs库,抛出 dayjs,
import { toTimeFormat, getPastTime, getDateDiff, dayjs } from "@vhen/fs-helper";| 函数 | 举例 | 描述 | | ------------ | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | | toTimeFormat | toTimeFormat(new Date(),'YYYY-MM-DD HH:mm:ss') | 时间格式化默认:YYYY-MM-DD HH:mm:ss | | getPastTime | getPastTime('2012-01-02 12:12:30', 2) | 过去日期(刚刚,几分钟之前等),第二个参数为 0 不格式时间,否则 2 表示大于 2 年显示格式化时间 YYYY-MM-DD HH:mm:ss | | getDateDiff | getDateDiff('2024-05-01', new Date(), 'day') | 判断相差天、月、年 ,类型:('day'、'months'、'years') | | getZodiac | getZodiac(2024) | 生肖 |
验证类
| 函数 | 举例 | 描述 | | ---------- | ---------------------------------- | ------------------ | | isPhone | isPhone('19606066920') | 是否为手机号码 | | isExternal | isExternal('http://www.baidu.com') | 是否是外部链接 | | isUrl | isUrl('http://www.baidu.com') | 验证是否是 url | | isImageUrl | isImageUrl('http://xxx.xxx.png') | 验证图片路径 | | isIdCard | isIdCard('350423199906154973') | 验证是否是身份证号 |
