zimo_util
v1.1.0
Published
``` 格式化日期 需要什么格式传入什么格式 yy-MM-dd hh:mm:ss
Downloads
24
Readme
dateFormat
格式化日期
需要什么格式传入什么格式
yy-MM-dd hh:mm:ss
getParams
获取url参数
传入全部网址
getParams(url)
dayFormat
获取星期几
传入时间戳
dayFormat(date)
getDateDiff(startTime, endTime)
获取两个时间差
startTime 开始时间(xxxx-xx-xx)
endTime 结束时间(xxxx-xx-xx)
dayDiff(sDate1, sDate2)
获取两个日期相差天数
传入xxxx-xx-xx
setCookie(name, value)
设置cookie
传入键值对
getCookie(name)
获取cookie
传入键名
delCookie(name)
删除某个cookie
传入键名
setStorageItem(itemName,value)
设置缓存
传入键,值
getStorageItem(itemName)
获取缓存
传入键名
clearStorage()
删除缓存,直接调用,无需传参
filterParams(obj)
清除对象中值为空的属性
当值等于0,null,undefined的时候,就会被过滤
render函数
var render = function(tpl,data){
return tpl.replace(/\{\{(.+?)\}\}/g,function(m,m1){
return data[m1]
})
}
render('我是{{name}},年龄{{age}},性别{{sex}}',{
name:'姓名',
age:18,sex:'女',
})
// "我是姓名,年龄18,性别女"
debounce(fn,time)节流防抖函数
传入一个匿名函数()=>{函数体内书写执行事件}
time可不传,默认间隔为1000毫秒