1.0.0 • Published 3 years ago

yuluoo-hospital-utils v1.0.0

Weekly downloads
3
License
ISC
Repository
-
Last release
3 years ago

玉螺 utils 工具包

utils

is

isBlank :检验是否为空值或空对象或空数组 eg:
isBlank([]); // true
isBlank({}); // true
isBlank(0); // true
isBlank(undefined); // true
isBlank(null); // true
isBlank(false); // true
isBlank(""); // true
isTypeof :判读数据类型
isTypeof([]); // 'array'
isTypeof(null); // 'null'  这里 null 的类型不再是 object
isTypeof(NaN); // 'NaN'  这里 NaN 的类型不再是 number
isLeapYear 是否是闰年
isLeapYear(); // 不传参数则取当前时间年份
isLeapYear(2008); // true
timeFormat :格式化日期
// y-m-d h:m:s  yyyy-mm-dd hh:mm:ss 都可以 只判断是否有 - / 年 字样
// 链接符
timeFormat("2021/01/25 14:23:26", "y-m-d h:m:s"); // "2021-01-25 14:23:26"
timeFormat("2021/01/25 14:23:26", "y/m/d h:m:s"); // "2021/01/25 14:23:26"
// hh:mm
timeFormat("2021/01/25 14:23:26", "y/m/d h:m"); // "2021/01/25 14:23"
// 数字时间戳
timeFormat(1611555806000, "y-m-d h:m"); // "2021/01/25 14:23:26"
// 字符串时间戳
timeFormat("1611555806000", "y-m-d h:m"); // "2021/01/25 14:23:26"
// 中文
timeFormat(new Date(), "y年m月d日 hh:mm:ss")); // 2021年01月26日 15:23:32
isIOS IOS 环境
isAndroid 安卓环境
isIOS(); // true | false
isAndroid(); // true | false
getQuery 获取路由参数
getQuery("http://localhost:8088/live?a=1&b=2&c=2"); // { a: "1", b: "2", c: "2" }
toFixed 保留几位小数
toFiexd("3.1415926", 2); // "3.14"
toFiexd(3.1415926, 2); // "3.14"
padStart 前补白 padEnd 后补白
// 值  要求多少个字符,不够字符数则在前或者后面补上 “0”
padStart("1", 2, "0"); // "01"
padStart("1", 4, "0"); // "0001"
padEnd("1", 2, "0"); // "10"
padEnd("1", 4, "0"); // "1000"

wx 相关

navigateToWithParam 页面跳转
navigateToWithParam({
  url: "http://localhost:8088/live",
  query: { a: "1", b: "2", c: "2" },
  success: () => {},
});

//  http://localhost:8088/live?a=1&b=2&c=2