npm.io
1.2.17 • Published 8 years ago

nrailsjs

Licence
MIT
Version
1.2.17
Deps
0
Size
950 kB
Vulns
0
Weekly
0

nrailsjs

前端工具库

安装

npm install nrailsjs  --s -d

使用

 // ES6
   import { subAndRemoveDate } from "nrailsjs/nTime";
插件说明

fullscreen.js

name Description param return Example
isFullscreen 判断当前是否为全屏状态 Boolean
isFullscreenEnabled 判断当前浏览器是否支持全屏模式 Boolean
listenFullScreen 对全屏事件添加监听 Function 函数
requestFullScreen 请求全屏
exitFullScreen 退出全屏
toggleFullScreen toggle(退出/请求)全屏

nArray.js

name Description param return Example
arrayEqual 判断两个数组是否相等 arr1(类型:Array),arr2(类型:Array)
sortBy 数组对象值比较排序 比较字段(field) (类型:String) Arry arry1.sort(sortBy("Order"));
cDictionary 得到字典信息 result(类型:Array),字段 field (类型:String) Map

nClass.js

name Description param return Example
addClass 为元素添加class ele (类型:String) ,样式 (cls) (类型:String)
hasClass 判断元素是否有某个class HTMLElement (ele) (类型:String),样式 (cls)(类型:String) Boolean
removeClass 为元素移除class HTMLElement (ele) (类型:String),样式 (cls) (类型:String)

nCookie.js

name Description param return Example
removeCookie 根据name删除cookie 名 (name)(类型:String)
getCookie 根据name读取cookie 名 (name) (类型:String) String
setCookie 设置Cookie 名 (name) (类型:String) 值(value)(类型:String),过去时间(days)(类型:Number)

nDevice.js

name Description param return Example
getExplore 获取浏览器类型和版本 String
getOS 获取操作系统类型 String
onresize 页面改变高度和宽度触发事件 cb(function) Object
getClientInfo 获取浏览器clientWidth,clientHeight cd

nDom.js

name Description param return Example
getScrollTop 获取滚动条距顶部的距离 Number
offset 获取一个元素的距离文档(document)的位置,类似jQ中的offset() HTMLElement (ele) Object
scrollTo 在${duration}时间内,滚动条平滑滚动到指定位置 指定位置 (to)(类型:Number),时间 (duration)(类型:Number)
setScrollTop 设置滚动条距顶部的距离 value (设置值) Number
scrollBottom 滚动条到底部触发 bot(底部距离的高度,默认:550),cb (滚动的回掉函数)

nIsSupport.js

name Description param return Example
isSupportWebP 判断浏览器是否支持webP格式图片 Boolean

nkeyCode.js

name Description param return Example
getKeyName 根据keycode获得键名 (键值) keycode (类型:Number) String 114: 'F3'

nMd5.js

name Description param return Example
hex_md5 hex_md5 要加密的值(s) (类型:String) String 114: 'F3'
b64_md5 b64_md5 要加密的值(s) (类型:String) String 114: 'F3'
str_md5 str_md5 要加密的值(s) (类型:String) String 114: 'F3'
hex_hmac_md5 hex_hmac_md5 key(类型:String),data(类型:String) String
b64_hmac_md5 b64_hmac_md5 key(类型:String),data(类型:String) String
b64_hmac_md5 b64_hmac_md5 key(类型:String),data(类型:String) String

nObject.js

name Description param return Example
deepClone 深拷贝,支持常见类型 values (类型:Object) String
deepCopy 数组深度拷贝,返回新数组 source (类型:Array) Array
isEmptyObject 判断obj对象是否为空 obj (类型:Object) Boolean
stringfyQueryString 对象序列化 obj (类型:Object) string

nRandom.js

name Description param return Example
randomColor 随机生成颜色 String
randomNum 生成指定范围[min, max]的随机数 最小值(min)(类型:Number),最大值 (max) (类型:Number) Number

nRegexp.js

name Description param return Example
isEmail 判断是否为邮箱地址 str (类型:String) Boolean
isIdCard 判断是否为身份证号 str (类型:String Number) Boolean
isPhoneNum 判断是否为手机号 str (类型:String Number) Boolean
isUrl 判断是否为URL地址 str (类型:String) Boolean

nString.js

name Description param return Example
digitUppercase 现金额转大写 num (类型:Number) String

nTime.js

name Description param return Example
formatPassTime 格式化${startTime}距现在的已过时间 startTime (类型:Date) String
formatRemainTime 格式化现在距${endTime}的剩余时间 endTime (类型:Date) String
subDate 截取时间字符串去掉秒后面的点, date (类型:string) String 2017-10-16 1924.818839 截取 2017-10-16 1924
removeDateT 去掉时间字符串中T字符 date (类型:string) String 2017-10-16T1924 截取2017-10-16 1924
subAndRemoveDate 去掉时间字符串中T字符去掉秒后面的点 date (类型:string) String
totalMillisecondOfDay 一天的毫秒数 String
totalMillisecondOfHour 一个小时的毫秒数 String
totalMillisecondOfMinute 一分钟的毫秒数 String
totalMillisecondOfSecond 一秒钏的毫秒数 String
dateTimeAddDays 为时间对象加/减指定的天数,返回新的时间对象 dateTime (类型:Date) ,nDays 天 (类型:Number) Date
dateTimeAddHours 为时间对象加/减指定的小时,返回新的时间对象 dateTime (类型:Date) ,nHours 小时 (类型:Number) Date
dateTimeAddMinutes 为时间对象加/减指定的分钟,返回新的时间对象 dateTime (类型:Date) ,nMinutes 分钟 (类型:Number) Date
dateTimeAddSeconds 减指定的秒数,返回新的时间对象 dateTime (类型:Date) ,nSeconds 秒 (类型:Number) Date
dateTimeBegin 返回时间对象当天的开始时间对象 dateTime (类型:Date) dateTime (类型:Date) Date
dateTimeEnd 返回时间对象当天的最后时间对象 dateTime (类型:Date) Date
dateTimeOfWeekBegin 返回时间对象当前周的开始日期时间,时间部分为 0时 0分 0秒 dateTime (类型:Date) Date
dateTimeOfWeekEnd 返回时间对象当前周的最后日期时间,时间部分为 23时 59分 59秒 dateTime (类型:Date) Date
dateTimeFormat 对Date的扩展,将 Date 转化为指定格式的String dateTime (类型:Date) ,fmt (类型:string) Date
dateTimeReplace 对时间进行替换,-替换/,T替换空去掉秒. 例如 2006-07-02T0804.423 转换后 2006/07/02 0804 strDateTime (类型:string) Date

nUrl.js

name Description param return Example
parseQueryString url参数转对象 url (类型:string) Object
getQueryString 根据传入的参数来获取值 name (类型:string) String
getUrlParams 获取url参数,转换对象默认不传参数是浏览器url地址 url (类型:string) String

UtilsExportExcel

name Description param return Example
exportExcel json数据导出.slxl 标题 tHeader (类型:Array) , 内容数据 list (类型:Array) (类型:string), 内容字段 filterVal (类型:Array), 文件名 title (类型:string)

nThrottle

name Description param return Example
debounce 函数防抖 fn (function), delay (int 毫秒) function
throttle 函数节流 fn (function), delay (int 毫秒) function