Methods
# $(selector) → {DOM|Null|Array}
根据选择器查找 DOM
Parameters:
| Name | Type | Description |
|---|---|---|
selector |
String | 选择器名称,用法同CSS选择器 |
- Source:
Returns:
群组选择器(含,)返回Array。其他选择器,找到返回第一个DOM,没有返回Null
- Type
- DOM | Null | Array
# addClass(node, className) → {DOM|ArrayLike}
添加类名
Parameters:
| Name | Type | Description |
|---|---|---|
node |
DOM | ArrayLike | 要添加类名的节点或节点列表 |
className |
String | Array | 要添加的类名 |
- Source:
Returns:
返回添加类名的节点或节点列表,与传参 node 相同
- Type
- DOM | ArrayLike
# debounce(callback, time) → {function}
防抖
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function | 回调函数 |
time |
Number | 延迟时间 |
- Source:
Returns:
防抖的函数
- Type
- function
# delHtmlTag(html) → {String}
富文本 → 纯文本
Parameters:
| Name | Type | Description |
|---|---|---|
html |
String | 富文本字符串 |
- Source:
Returns:
返回纯文本字符串
ALL HTML TAG List Source:https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element
- Type
- String
# getAbsoluteUrl(url) → {String}
获取绝对路径
Parameters:
| Name | Type | Description |
|---|---|---|
url |
String | // 相对路径 |
- Source:
Returns:
// 返回路径的值与浏览器处理相对路径相同
- Type
- String
# htmlEncode(html) → {String}
转义:HTML → HTMLEntites
Parameters:
| Name | Type | Description |
|---|---|---|
html |
String | 富文本字符串 |
- Source:
Returns:
返回转义后的字符串,转换非ASCII编码字符
- Type
- String
# insertAfter(node, target) → {DOM|ArrayLike}
在 target 节点之后插入 node 节点
Parameters:
| Name | Type | Description |
|---|---|---|
node |
DOM | ArrayLike | 要插入的节点或节点列表 |
target |
DOM | Null | 插入目标节点的后方,若目标节点不存在,则插入父节点的末尾 |
- Source:
Returns:
返回被插入的节点或节点列表,与传参 node 相同
- Type
- DOM | ArrayLike
# isRefererValid(referer, nullable, })
Parameters:
| Name | Type | Description |
|---|---|---|
referer |
String | 来源 |
nullable |
Boolean | 允许为空:默认允许 |
} |
Array | whiteList 白名单:域名 + 端口 白名单(不含http和https) |
- Source:
# javaScriptEncode(js) → {String}
转义:JavaScript代码 → 字符串
Parameters:
| Name | Type | Description |
|---|---|---|
js |
String | JavaScript代码 |
- Source:
Returns:
返回转义后的字符串,转换非ASCII编码字符
- Type
- String
# query(name, querystring) → {String|undefined}
获取指定的 querystring 中指定 name 的 value
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String | 查询名 |
querystring |
String | 查询到的值 |
- Source:
Returns:
查询到返回String,没有返回undefined
- Type
- String | undefined
# removeClass(node, className) → {DOM|ArrayLike}
移除类名
Parameters:
| Name | Type | Description |
|---|---|---|
node |
DOM | Array.<Dom> | 要移除类名的节点或节点列表 |
className |
String | Array | 要移除的类名 |
- Source:
Returns:
返回移除类名的节点或节点列表,与传参 node 相同
- Type
- DOM | ArrayLike
# removeItemByIndex(index, arr) → {Array}
根据索引移出数组的某一项
Parameters:
| Name | Type | Description |
|---|---|---|
index |
Number | 要删除的索引。正负和边界处理与Array.prototype.splice的第一参数相同 |
arr |
Array | 要操作的数组 |
- Source:
Returns:
返回操作后的数组
- Type
- Array
# removeItemByValue(index, arr) → {Array}
根据值移出数组的某一项
Parameters:
| Name | Type | Description |
|---|---|---|
index |
Number | 要删除的值。严格相等匹配与Array.prototype.indexOf相同 |
arr |
Array | 要操作的数组 |
- Source:
Returns:
返回操作后的数组
- Type
- Array
# removeNode(node) → {DOM|ArrayLike}
删除 DOM 节点
Parameters:
| Name | Type | Description |
|---|---|---|
node |
DOM | ArrayLike | 要删除的节点或节点列表 |
- Source:
Returns:
返回值被删除的节点或节点列表,与传参 node 相同
- Type
- DOM | ArrayLike
# serialize(data) → {String}
序列化对象,把对象转成URL查询字符串
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | 对象 |
- Source:
Returns:
返回查询字符串
- Type
- String
# stringifyJSON(obj) → {String}
JSON.stringify:保留对象中undefined、BigInt值和Function、Symbol结构
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Object | JS对象 |
- Source:
Returns:
返回序列化后的字符串
- Type
- String
# throttle(callback, time) → {function}
节流
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function | 回调函数 |
time |
Number | 时间间隔 |
- Source:
Returns:
节流的函数
- Type
- function