# common **Repository Path**: saqqdy/common ## Basic Information - **Project Name**: common - **Description**: 一些常用的js方法封装 - **Primary Language**: JavaScript - **License**: ISC - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 4 - **Created**: 2018-12-22 - **Last Updated**: 2021-07-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # @saqqdy/common ### 介绍 JS常用方法,来自于本人前端多年经验积累 ### 软件架构 集成了大量常用方法,采用了纯原生ES6+babel+webpack的开发方式 ### 安装教程 ``` # 通过npm安装 npm install --save @saqqdy/common # 或者通过yarn安装 yarn add @saqqdy/common ``` #### 通过import引入模块的方式 ``` # 在你的.vue或者main.js里面写上import import { trim, getOsVersion, ... } from '@saqqdy/common' # 使用 trim(somestring, type) // 返回清理空格后的字符串 getOsVersion() // 返回系统版本 ... ``` #### 使用文件引入的方式 1. 通过require引入 ``` # 在你的main.js文件里面加上下面这一行 require('@saqqdy/common') ``` 2. html静态页直接使用 ``` # 在你的html代码上加上script标签,使用CDN链接引入 ``` ### 所有方法汇总 ``` // 全局参数 client, // client方法返回一个浏览器判断结果对象 pattern, // pattern返回一些常用的正则 // String扩展、数组方法 trim, // 根据传参来去除空格 clearAttr, // 去除HTML标签所有属性 clearBr, // 去除换行 clearHtml, // 去除HTML标签 clearHtmlExpSN, // 去除HTML标签保留空格、换行 clearHtmlN, // 去除HTML标签及换行 clearHtmlNS, // 去除HTML标签及空格、换行 clearHtmlTag, // 去除HTML标签及标签里面的文字 getNumber, // 获取字符串中的数字 imgAdapt, // 扩展图片自动适应多种分辨率small original imgChoose, // 扩展图片自动适应多种分辨率@2x @3x camel2Dash, // 将驼峰字符串转成-间隔且全小写的Dash模式 dash2Camel, // 将-间隔且全小写的Dash模式转成驼峰字符串 getRandomNum, // 获取随机整数 getRandomStr, // 获取随机字符串 getRandomStrWidthSpecialChar, // 获取随机字符串带特殊符号 getCHSLength, // 获取字符串长度,中文算2个字符 cutCHSString, // 截取字符串,中文算2个字节 textareaInsertText, // textarea或input对象在指定的光标位置插入文字 textareaMoveToEnd, // textarea或input对象将光标定位到文字尾部 // 获取一下状态 isDigitals, // 是否为由数字组成的字符串 isExitsFunction, // 是否存在指定函数 isExitsVariable, // 是否存在指定变量 getWindowSize, // getWindowSize获取窗口大小 getAppVersion, // 获取APP版本号 getOsVersion, // 获取手机系统版本 getIsAppVersionLastest, // 版本号大小对比 getDirParam, // 获取目录形式URL参数 getParameter, // 获取单个URL参数 getFileType, // 文件后缀名 getUrlParam, // 获取URL参数 // 日期格式化 formatTime, // 日期格式化插件 formatTimeStr, // 格式化时间成:刚刚、几分钟前 // 缓存、cookie、session setCookie, // setCookie写入cookie的方法 setLocal, // 写localStorage setSession, // 写sessionStorage getCookie, // 读取cookies getLocal, // 读取localStorage getSession, // 读取sessionStorage delCookie, // 删除cookie delLocal, // 删除localStorage delSession, // 删除sessionStorage // 编码与解码 encodeBase64, // 字符串、数字转base64 encodeUtf8, // 编码Utf8 decodeBase64, // base64解码 decodeUtf8, // 解码Utf8 enWxJumpLink, // 用*替换= 用!替换& 转码成微信跳转链接 enWxJumpLinkOld, // 用~替换= 用^替换& 转码成微信跳转链接 deWxJumpLink, // 用=替换* 用&替换! 解码成微信跳转链接 deWxJumpLinkOld, // 用=替换~ 用&替换^ 解码成微信跳转链接 // 防抖与限流 debounce, // 空闲控制 返回函数连续调用时,空闲时间必须大于或等于 delay,fn 才会执行 throttle, // 频率控制 返回函数连续调用时,fn 执行频率限定为每多少时间执行一次 // 事件委托、其他事件方法 stopBubble, // 阻止冒泡 stopDefault, // 阻止默认事件 addEvent, // 事件委托,支持多次委托 removeEvent, // removeEvent移除由addEvent创建的事件委托 getScrollPosition, // 获取滑动到顶部和底部 返回'top' 'bottom',建议使用限流 ``` ### API文档
addEvent(element, type, handler)

addEvent()事件委托,支持多次委托

handleEvent(event) ⇒ Boolean

handleEvent()执行事件

fixEvent(event) ⇒ Object

为IE的事件对象添加一些“缺失的”函数

camel2Dash(string) ⇒ String

camel2Dash 将驼峰字符串转成-间隔且全小写的Dash模式

clearAttr(string) ⇒ String

去除HTML标签所有属性

clearBr(string) ⇒ String

去除换行

clearHtml(string) ⇒ String

去除HTML标签

clearHtmlExpSN(string) ⇒ String

去除HTML标签保留空格、换行

clearHtmlN(string) ⇒ String

去除HTML标签及换行

clearHtmlNS(string) ⇒ String

去除HTML标签及空格、换行

clearHtmlTag(string) ⇒ String

去除HTML标签及标签里面的文字

client(name, userAgent) ⇒ Object | Boolean

client方法返回一个浏览器判断结果:{ ANDROID: true, GECKO: true, GLSH_APP: false, IE: false, IOS: false, IPAD: false, IPHONE: false, MOBILE: true, MOBILEDEVICE: true, OPERA: false, QQ: false, QQBROWSER: false, TRIDENT: false, WEBKIT: true, WEIXIN: false }

cutCHSString(str, len, hasDot) ⇒ String

截取字符串,中文算2个字节

dash2Camel(string) ⇒ String

dash2Camel 将-间隔且全小写的Dash模式转成驼峰字符串

deWxJumpLink(string) ⇒ String

用=替换 用&替换! 解码成微信跳转链接 nameexMall-detail-goodsInfoId!params(goodsInfoId)*8866 转成 name=exMall-detail-goodsInfoId&params[goodsInfoId]=8866

deWxJumpLinkOld(string) ⇒ String

用=替换~ 用&替换^ 解码成微信跳转链接

debounce(fn, delay, immediate) ⇒ function

空闲控制 返回函数连续调用时,空闲时间必须大于或等于 delay,fn 才会执行

decodeBase64(input) ⇒ String

base64解码

decodeUtf8(input) ⇒ String

解码Utf8

delCookie(name)

删除cookie

delLocal(name)

删除localStorage

delSession(name)

删除sessionStorage

enWxJumpLink(string) ⇒ String

用替换= 用!替换& 转码成微信跳转链接 name=exMall-detail-goodsInfoId&params[goodsInfoId]=8866 转成 nameexMall-detail-goodsInfoId!params(goodsInfoId)*8866

enWxJumpLinkOld(string) ⇒ String

用~替换= 用^替换& 转码成微信跳转链接

encodeBase64(input) ⇒ String

字符串、数字转base64

encodeUtf8(input) ⇒ String

编码Utf8

formatTime(time, fmt) ⇒ String

日期格式化插件 使用方式:formatTime(new Date(), "yyyy-MM-dd")

formatTimeStr(time, fmt) ⇒ String

格式化时间成:刚刚、几分钟前

getAppVersion(appName, withosstr, userAgent) ⇒ Boolean | null

获取APP版本号

getCHSLength(str) ⇒ Number

获取文本长度,中文算2个字节

getCookie(name) ⇒ String

读取cookies

getDirParam(url) ⇒ Object

获取目录形式URL参数

getFileType(url) ⇒ String

文件后缀名

getIsAppVersionLastest(appName, compareVer, userAgent) ⇒ Boolean | null

版本号大小对比

getLocal(name) ⇒ String

读取localStorage

getNumber(string) ⇒ String

获取字符串中的数字

getOsVersion(osName, withosstr, userAgent) ⇒ Boolean | null

获取手机系统版本

getParameter(name) ⇒

获取单个URL参数

getRandomNum(min, max) ⇒ Number

获取随机整数

getRandomStr(len, widthSpecialChar) ⇒ String

获取随机字符串

getRandomStrWidthSpecialChar(len) ⇒ String

获取随机字符串带特殊符号

getScrollPosition() ⇒ String

获取滑动到顶部和底部 返回'top' 'bottom',建议使用限流

getSession(name) ⇒ String

读取sessionStorage

getUrlParam(url) ⇒ Object

获取URL参数

getWindowSize() ⇒ Object

getWindowSize获取窗口大小

imgAdapt(imgurl, size) ⇒ String

扩展图片自动适应多种分辨率small original

imgChoose(imgurl) ⇒ String

扩展图片自动适应多种分辨率@2x @3x

isDigitals(str) ⇒ Boolean

是否为由数字组成的字符串

isExitsFunction(funcName) ⇒ Boolean

是否存在指定函数

isExitsVariable(variableName) ⇒ Boolean

是否存在指定变量

pattern() ⇒ Object

pattern返回一些常用的正则:any, arrjson, chinese, email, float, isjson, json, mobile, number, pass, postcode, qq, string, tel, textarea, url, username

removeEvent(element, type, handler)

removeEvent移除由addEvent创建的事件委托

setCookie(name, value, seconds)

setCookie写入cookie的方法

setLocal(name, value, seconds)

写localStorage

setSession(name, value, seconds)

写sessionStorage

stopBubble(e) ⇒ Boolean

阻止冒泡

stopDefault(e) ⇒ Boolean

阻止默认事件

textareaInsertText(obj, str)

textarea或input对象在指定的光标位置插入文字

textareaMoveToEnd(obj)

textarea或input对象将光标定位到文字尾部

throttle(fn, delay, immediate) ⇒ function

频率控制 返回函数连续调用时,fn 执行频率限定为每多少时间执行一次

trim(string, type) ⇒ String

trim()根据传参来去除空格

## addEvent(element, type, handler) addEvent()事件委托,支持多次委托 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | element | Object | js dom对象 | | type | String | 事件类型。不需要加on | | handler | function | 回调方法 | ## handleEvent(event) ⇒ Boolean handleEvent()执行事件 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | event | String | 事件类型 | ## fixEvent(event) ⇒ Object 为IE的事件对象添加一些“缺失的”函数 **Kind**: global function **Returns**: Object - 返回补齐了缺失方法的的event | Param | Type | Description | | --- | --- | --- | | event | String | 事件类型 | ## camel2Dash(string) ⇒ String camel2Dash 将驼峰字符串转成-间隔且全小写的Dash模式 **Kind**: global function **Returns**: String - 返回转换后的字符串 | Param | Type | Description | | --- | --- | --- | | string | String | 需要转换的字符串 | ## clearAttr(string) ⇒ String 去除HTML标签所有属性 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | string | String | 传入字符串 | ## clearBr(string) ⇒ String 去除换行 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | string | String | 带html标签的字符串 | ## clearHtml(string) ⇒ String 去除HTML标签 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | string | String | 带html标签的字符串 | ## clearHtmlExpSN(string) ⇒ String 去除HTML标签保留空格、换行 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | string | String | 带html标签的字符串 | ## clearHtmlN(string) ⇒ String 去除HTML标签及换行 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | string | String | 带html标签的字符串 | ## clearHtmlNS(string) ⇒ String 去除HTML标签及空格、换行 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | string | String | 带html标签的字符串 | ## clearHtmlTag(string) ⇒ String 去除HTML标签及标签里面的文字 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | string | String | 带html标签的字符串 | ## client(name, userAgent) ⇒ Object \| Boolean client方法返回一个浏览器判断结果:{ ANDROID: true, GECKO: true, GLSH_APP: false, IE: false, IOS: false, IPAD: false, IPHONE: false, MOBILE: true, MOBILEDEVICE: true, OPERA: false, QQ: false, QQBROWSER: false, TRIDENT: false, WEBKIT: true, WEIXIN: false } **Kind**: global function **Returns**: Object \| Boolean - 返回常用ua匹配表,如果传了name,那么返回是否匹配该终端true/false | Param | Type | Description | | --- | --- | --- | | name | String | 可选,比如传入MicroMessenger,返回是否为微信内置浏览器 | | userAgent | String | 可选,传入自定义的ua,默认取浏览器的navigator.appVersion | ## cutCHSString(str, len, hasDot) ⇒ String 截取字符串,中文算2个字节 **Kind**: global function **Returns**: String - 返回截取后的字符串 | Param | Type | Default | Description | | --- | --- | --- | --- | | str | String | | 要截取的字符串 | | len | Number | | | | hasDot | Boolean | false | | ## dash2Camel(string) ⇒ String dash2Camel 将-间隔且全小写的Dash模式转成驼峰字符串 **Kind**: global function **Returns**: String - 返回转换后的字符串 | Param | Type | Description | | --- | --- | --- | | string | String | 需要转换的字符串 | ## deWxJumpLink(string) ⇒ String 用=替换* 用&替换! 解码成微信跳转链接 name*exMall-detail-goodsInfoId!params(goodsInfoId)*8866 转成 name=exMall-detail-goodsInfoId¶ms[goodsInfoId]=8866 **Kind**: global function **Returns**: String - 返回解码结果 | Param | Type | Description | | --- | --- | --- | | string | String | 传入字符串 | ## deWxJumpLinkOld(string) ⇒ String 用=替换~ 用&替换^ 解码成微信跳转链接 **Kind**: global function **Returns**: String - 返回解码结果 | Param | Type | Description | | --- | --- | --- | | string | String | 传入字符串 | ## debounce(fn, delay, immediate) ⇒ function 空闲控制 返回函数连续调用时,空闲时间必须大于或等于 delay,fn 才会执行 **Kind**: global function **Returns**: function - 实际调用函数 | Param | Type | Description | | --- | --- | --- | | fn | function | 要调用的函数 | | delay | number | 空闲时间 | | immediate | bool | 给 immediate参数传递false 绑定的函数先执行,而不是delay后后执行。 | ## decodeBase64(input) ⇒ String base64解码 **Kind**: global function **Returns**: String - 解码后的字符串 | Param | Type | Description | | --- | --- | --- | | input | String | 需要解码的字符串 | ## decodeUtf8(input) ⇒ String 解码Utf8 **Kind**: global function **Returns**: String - 解码后的字符串 | Param | Type | Description | | --- | --- | --- | | input | String | 需要解码的字符串 | ## delCookie(name) 删除cookie **Kind**: global function | Param | Type | Description | | --- | --- | --- | | name | String | cookie名称 | ## delLocal(name) 删除localStorage **Kind**: global function | Param | Type | Description | | --- | --- | --- | | name | String | 名称 | ## delSession(name) 删除sessionStorage **Kind**: global function | Param | Type | Description | | --- | --- | --- | | name | String | 名称 | ## enWxJumpLink(string) ⇒ String 用*替换= 用!替换& 转码成微信跳转链接 name=exMall-detail-goodsInfoId¶ms[goodsInfoId]=8866 转成 name*exMall-detail-goodsInfoId!params(goodsInfoId)*8866 **Kind**: global function **Returns**: String - 返回转码结果 | Param | Type | Description | | --- | --- | --- | | string | String | 传入字符串 | ## enWxJumpLinkOld(string) ⇒ String 用~替换= 用^替换& 转码成微信跳转链接 **Kind**: global function **Returns**: String - 返回转码结果 | Param | Type | Description | | --- | --- | --- | | string | String | 传入字符串 | ## encodeBase64(input) ⇒ String 字符串、数字转base64 **Kind**: global function **Returns**: String - 返回BASE64编码 | Param | Type | Description | | --- | --- | --- | | input | String | 需要编码的字符串 | ## encodeUtf8(input) ⇒ String 编码Utf8 **Kind**: global function **Returns**: String - 返回UTF-8编码 | Param | Type | Description | | --- | --- | --- | | input | String | 需要编码的字符串 | ## formatTime(time, fmt) ⇒ String 日期格式化插件 使用方式:formatTime(new Date(), "yyyy-MM-dd") **Kind**: global function **Returns**: String - 返回字符串 | Param | Type | Default | Description | | --- | --- | --- | --- | | time | Date/String | | 时间对象或者字符串 | | fmt | String | yyyy-MM-dd | 格式化风格 | ## formatTimeStr(time, fmt) ⇒ String 格式化时间成:刚刚、几分钟前 **Kind**: global function **Returns**: String - 返回字符串 | Param | Type | Description | | --- | --- | --- | | time | Date/String | 时间对象或者字符串 | | fmt | String | 格式化风格 | ## getAppVersion(appName, withosstr, userAgent) ⇒ Boolean \| null 获取APP版本号 **Kind**: global function **Returns**: Boolean \| null - null/true/false | Param | Type | Description | | --- | --- | --- | | appName | String | app名称 | | withosstr | Boolean | 是否需要带上名称 | | userAgent | String | ua,可不传,默认取navigator.appVersion | ## getCHSLength(str) ⇒ Number 获取文本长度,中文算2个字节 **Kind**: global function **Returns**: Number - 返回长度 | Param | Type | Description | | --- | --- | --- | | str | String | 字符串 | ## getCookie(name) ⇒ String 读取cookies **Kind**: global function **Returns**: String - 返回cookie字符串 | Param | Type | Description | | --- | --- | --- | | name | String | cookie名称 | ## getDirParam(url) ⇒ Object 获取目录形式URL参数 **Kind**: global function **Returns**: Object - 返回参数对象 | Param | Type | Description | | --- | --- | --- | | url | String | 传入url地址 | ## getFileType(url) ⇒ String 文件后缀名 **Kind**: global function **Returns**: String - 返回文件后缀 | Param | Type | Description | | --- | --- | --- | | url | String | 文件名 | ## getIsAppVersionLastest(appName, compareVer, userAgent) ⇒ Boolean \| null 版本号大小对比 **Kind**: global function **Returns**: Boolean \| null - null/true/false | Param | Type | Description | | --- | --- | --- | | appName | String | app名称 | | compareVer | String | 必传 需要对比的版本号 | | userAgent | String | ua,可不传,默认取navigator.appVersion | ## getLocal(name) ⇒ String 读取localStorage **Kind**: global function **Returns**: String - 返回localStorage | Param | Type | Description | | --- | --- | --- | | name | String | 名称 | ## getNumber(string) ⇒ String 获取字符串中的数字 **Kind**: global function **Returns**: String - 返回纯数字字符串 | Param | Type | Description | | --- | --- | --- | | string | String | 传入带数字的字符串 | ## getOsVersion(osName, withosstr, userAgent) ⇒ Boolean \| null 获取手机系统版本 **Kind**: global function **Returns**: Boolean \| null - null/true/false | Param | Type | Description | | --- | --- | --- | | osName | String | 系统类型字符串Android、iPod、iWatch或iPhone | | withosstr | Boolean | 是否需要带上名称 | | userAgent | String | ua,可不传,默认取navigator.appVersion | ## getParameter(name) ⇒ 获取单个URL参数 **Kind**: global function **Returns**: 返回参数值 | Param | Type | Description | | --- | --- | --- | | name | String | 参数名称 | ## getRandomNum(min, max) ⇒ Number 获取随机整数 **Kind**: global function **Returns**: Number - 返回数字 | Param | Type | Default | Description | | --- | --- | --- | --- | | min | Number | 1 | 随机数的最小值 | | max | Number | 10 | 随机数的最大值 | ## getRandomStr(len, widthSpecialChar) ⇒ String 获取随机字符串 **Kind**: global function **Returns**: String - 随机串 | Param | Type | Default | Description | | --- | --- | --- | --- | | len | Number | 32 | 需要获取随机字符串的长度 | | widthSpecialChar | Boolean | false | 可选,是否需要生成带特殊字符的串 | ## getRandomStrWidthSpecialChar(len) ⇒ String 获取随机字符串带特殊符号 **Kind**: global function **Returns**: String - 随机串 | Param | Type | Default | Description | | --- | --- | --- | --- | | len | Number | 32 | 需要获取随机字符串的长度 | ## getScrollPosition() ⇒ String 获取滑动到顶部和底部 返回'top' 'bottom',建议使用限流 **Kind**: global function **Returns**: String - 返回位置 ## getSession(name) ⇒ String 读取sessionStorage **Kind**: global function **Returns**: String - 返回sessionStorage | Param | Type | Description | | --- | --- | --- | | name | String | 名称 | ## getUrlParam(url) ⇒ Object 获取URL参数 **Kind**: global function **Returns**: Object - 返回参数列表 | Param | Type | Description | | --- | --- | --- | | url | String | 传入url参数 | ## getWindowSize() ⇒ Object getWindowSize获取窗口大小 **Kind**: global function **Returns**: Object - 返回宽高 ## imgAdapt(imgurl, size) ⇒ String 扩展图片自动适应多种分辨率small original **Kind**: global function **Returns**: String - 返回新地址 | Param | Type | Description | | --- | --- | --- | | imgurl | String | 图片url | | size | String | 图片规格 | ## imgChoose(imgurl) ⇒ String 扩展图片自动适应多种分辨率@2x @3x **Kind**: global function **Returns**: String - 返回新地址 | Param | Type | Description | | --- | --- | --- | | imgurl | String | 图片地址 | ## isDigitals(str) ⇒ Boolean 是否为由数字组成的字符串 **Kind**: global function **Returns**: Boolean - 返回true/false | Param | Type | Description | | --- | --- | --- | | str | String | 待检测的字符串 | ## isExitsFunction(funcName) ⇒ Boolean 是否存在指定函数 **Kind**: global function **Returns**: Boolean - 返回true/false | Param | Type | Description | | --- | --- | --- | | funcName | String | 传入函数名 | ## isExitsVariable(variableName) ⇒ Boolean 是否存在指定变量 **Kind**: global function **Returns**: Boolean - 返回true/false | Param | Type | Description | | --- | --- | --- | | variableName | String | 传入变量名称 | ## pattern() ⇒ Object pattern返回一些常用的正则:any, arrjson, chinese, email, float, isjson, json, mobile, number, pass, postcode, qq, string, tel, textarea, url, username **Kind**: global function **Returns**: Object - 返回对象 ## removeEvent(element, type, handler) removeEvent移除由addEvent创建的事件委托 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | element | Object | js dom对象 | | type | String | 事件类型。不需要加on | | handler | function | 回调方法 | ## setCookie(name, value, seconds) setCookie写入cookie的方法 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | name | String | cookie名称 | | value | \* | 设置要存储的值,可以是对象或字符串 | | seconds | Number | cookie有效时间 | ## setLocal(name, value, seconds) 写localStorage **Kind**: global function | Param | Type | Description | | --- | --- | --- | | name | String | 名称 | | value | \* | 设置要存储的值,可以是对象或字符串 | | seconds | Number | 有效时间 | ## setSession(name, value, seconds) 写sessionStorage **Kind**: global function | Param | Type | Description | | --- | --- | --- | | name | String | 名称 | | value | \* | 设置要存储的值,可以是对象或字符串 | | seconds | Number | 有效时间 | ## stopBubble(e) ⇒ Boolean 阻止冒泡 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | e | Object | dom的event对象 | ## stopDefault(e) ⇒ Boolean 阻止默认事件 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | e | Object | dom的event对象 | ## textareaInsertText(obj, str) textarea或input对象在指定的光标位置插入文字 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | obj | Object | dom对象 | | str | String | 要插入的文字 | ## textareaMoveToEnd(obj) textarea或input对象将光标定位到文字尾部 **Kind**: global function | Param | Type | Description | | --- | --- | --- | | obj | Object | dom对象 | ## throttle(fn, delay, immediate) ⇒ function 频率控制 返回函数连续调用时,fn 执行频率限定为每多少时间执行一次 **Kind**: global function **Returns**: function - 实际调用函数 | Param | Type | Description | | --- | --- | --- | | fn | function | 需要调用的函数 | | delay | number | 延迟时间,单位毫秒 | | immediate | bool | 给 immediate参数传递false 绑定的函数先执行,而不是delay后后执行。 | ## trim(string, type) ⇒ String trim()根据传参来去除空格 **Kind**: global function **Returns**: String - 返回新字符串 | Param | Type | Description | | --- | --- | --- | | string | String | 传入字符串 | | type | string | 可选,去除空格的类型l:去除开头空格 r:去除尾部空格 lr:去除两端空格,为空的话去除所有空格 | ### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request ### 我的相关 - ***使用*** _Readme\_XXX.md_ 来支持不同的语言,`例如` _Readme\_en.md, Readme\_zh.md_ - 我的码云:[https://gitee.com/saqqdy](https://gitee.com/saqqdy) - 我的Github:[https://github.com/saqqdy](https://github.com/saqqdy) - 我的npm:[https://npmjs.com/~saqqdy](https://npmjs.com/~saqqdy) - 我的个人网站 [http://www.saqqdy.com](http://www.saqqdy.com)