Skip to content

Commit a915443

Browse files
committed
js change to md
1 parent 076a6a4 commit a915443

14 files changed

+97
-46
lines changed

Native-JavaScript/ajax.js Native-JavaScript/ajax.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### ajax request
2+
````js
13
/**
24
* @function ajax request
35
* @fields ajaxName:请求名称,method:请求方法,headers:setRequestHeader自定义部分,url:接口地址,async:是否异步请求,withCredentials:是否支持跨域发送cookie,dataType:数据类型 ,data:post请求参数
@@ -115,3 +117,4 @@ function ajaxPostData (ajaxName, requestUrl, params, async, callBack, contentTyp
115117
}
116118
})
117119
}
120+
````

Native-JavaScript/cancel-bubble.js Native-JavaScript/cancel-bubble.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### 传入event则阻止冒泡
2+
````js
13
/**
24
* 可以传入event则阻止冒泡,不传不阻止
35
* @param event
@@ -9,4 +11,5 @@ function someClick (event) {
911
window.event.cancelBubble = true // IE
1012
}
1113
// TODO 需要阻止冒泡的事件
12-
}
14+
}
15+
````

Native-JavaScript/data-handle.js Native-JavaScript/data-handle.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### 保留小数并千分位格式化
2+
````js
13
/**
24
* 保留小数并千分位格式化
35
* @param number
@@ -21,7 +23,10 @@ function thousandsFormateTofixed (number, digit, showZero) {
2123
}
2224
return result
2325
}
26+
````
2427

28+
###### 递归遍历数组对象,将结果去重
29+
````js
2530
/**
2631
* 递归遍历数组对象,将结果去重
2732
* @returns {*}
@@ -190,7 +195,10 @@ var getAllType = function () {
190195
}, [])
191196
return result
192197
}
198+
````
193199

200+
###### 数字单位格式化
201+
````js
194202
/**
195203
* 数字单位格式化
196204
* @param number
@@ -208,7 +216,10 @@ function formatterNumberUnit (number) {
208216
}
209217
return result
210218
}
219+
````
211220

221+
###### 获取对象长度
222+
````js
212223
/**
213224
* 获取对象长度
214225
* @param obj
@@ -223,3 +234,4 @@ function getObjectLength (obj) {
223234
}
224235
return count
225236
}
237+
````

Native-JavaScript/data-type-handle.js Native-JavaScript/data-type-handle.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### 合并两个函数
2+
````js
13
/**
24
* 合并两个函数
35
* @param functionA 先执行
@@ -13,7 +15,10 @@ function mergeFunction (functionA, functionB) {
1315
})()
1416
return functionB = merge
1517
}
18+
````
1619

20+
###### 深度比较两个对象是否相等
21+
````js
1722
/**
1823
* 深度比较两个对象是否相等
1924
* @type {{compare: compareObj.compare, isObject: (function(*=): boolean), isArray: (function(*=): boolean)}}
@@ -57,4 +62,5 @@ var compareObj = {
5762
isArray: function (arr) {
5863
return Object.prototype.toString.call(arr) === '[object Array]'
5964
}
60-
}
65+
}
66+
````

Native-JavaScript/dom-handle.js Native-JavaScript/dom-handle.md

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// DOM 相关处理
1+
###### 监听浏览器标签页的显示与隐藏
22

3+
````js
34
/**
45
* 监听浏览器标签页的显示与隐藏
56
*/
@@ -60,4 +61,30 @@ navChange.linsternVisibility(
6061
() => {
6162
// TODO 浏览器标签页处于显示状态时,执行的方法
6263
}
63-
)
64+
)
65+
66+
````
67+
68+
###### 监听dom变化
69+
````js
70+
/**
71+
* 监听dom变化
72+
* @param callback
73+
*/
74+
function monitorDomChange (callback) {
75+
var mutationObserver = new MutationObserver(function (mutations) {
76+
mutations.forEach(function (mutation) {
77+
callback(mutation)
78+
})
79+
})
80+
// 开始侦听页面的根 HTML 元素中的更改。
81+
mutationObserver.observe(document.documentElement, {
82+
attributes: true,
83+
characterData: true,
84+
childList: true,
85+
subtree: true,
86+
attributeOldValue: true,
87+
characterDataOldValue: true
88+
})
89+
}
90+
````

Native-JavaScript/encryption-decryption/base64.js Native-JavaScript/encryption-decryption/base64.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### abse64
2+
````js
13
/**
24
* @function decode encode base64 string
35
* @constructor Base64Function
@@ -97,3 +99,4 @@ function Base64Function () {
9799

98100
const Base64 = new Base64Function()
99101
export default {encode: Base64.encode, decode: Base64.decode}
102+
````
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
// Json字符串格式化
1+
###### Json字符串格式化
2+
````js
23
function jsonFormat (string) {
34
if (string === "") {
45
return ""
56
}
67
var result = JSON.parse(string)
78
return JSON.stringify(result, null, 4)
8-
}
9+
}
10+
````

Native-JavaScript/monitor-dom-change.js

-20
This file was deleted.

Native-JavaScript/scroll-handle.js Native-JavaScript/scroll-handle.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// 滚动条位置处理
1+
###### 滚动条位置处理
2+
````js
23
var scrollPosition = {
34
// 位置
45
result: 0,
@@ -20,4 +21,5 @@ var scrollPosition = {
2021
setPostion: function () {
2122
window.scrollTo(document.body.scrollWidth, scrollPosition.result)
2223
}
23-
}
24+
}
25+
````

Native-JavaScript/url-param.js Native-JavaScript/url-param.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### 获取hash或者search参数值
2+
````js
13
/**
24
* 获取hash或者search参数值
35
* @param paramName
@@ -10,3 +12,4 @@ function getParam (paramName) {
1012
var reg = new RegExp("(^|&)" + paramName + "=([^&]*)(&|$)", "i")
1113
return result.match(reg) !== null ? decodeURI(result.match(reg)[2]) : null
1214
}
15+
````

README.md

+17-16
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* <details>
1010
<summary>加密解密</summary>
1111
12-
- [base64](/Native-JavaScript/encryption-decryption/base64.js)
12+
- [base64](/Native-JavaScript/encryption-decryption/base64.md#abse64)
1313
</details>
1414

1515
* <details>
@@ -28,47 +28,48 @@
2828
* <details>
2929
<summary>Json数据处理</summary>
3030

31-
- [Json字符串格式化](/Native-JavaScript/json-handle.js)
31+
- [Json字符串格式化](/Native-JavaScript/json-handle.md#Json字符串格式化)
3232
</details>
3333

3434
* <details>
3535
<summary>数据格式化处理</summary>
3636

37-
- [保留小数并千分位格式化](/Native-JavaScript/data-handle.js)
38-
- [递归遍历数组对象,将结果去重](/Native-JavaScript/data-handle.js)
39-
- [数字单位格式化](/Native-JavaScript/data-handle.js)
40-
- [获取对象长度](/Native-JavaScript/data-handle.js)
37+
- [保留小数并千分位格式化](/Native-JavaScript/data-handle.md#保留小数并千分位格式化)
38+
- [递归遍历数组对象,将结果去重](/Native-JavaScript/data-handle.md#递归遍历数组对象,将结果去重)
39+
- [数字单位格式化](/Native-JavaScript/data-handle.md#数字单位格式化)
40+
- [获取对象长度](/Native-JavaScript/data-handle.md#获取对象长度)
4141
</details>
4242

4343
* <details>
4444
<summary>数据类型处理</summary>
4545

46-
- [合并两个函数](/Native-JavaScript/data-type-handle.js)
47-
- [深度比较两个对象是否相等](/Native-JavaScript/data-type-handle.js)
46+
- [合并两个函数](/Native-JavaScript/data-type-handle.md#合并两个函数)
47+
- [深度比较两个对象是否相等](/Native-JavaScript/data-type-handle.md#深度比较两个对象是否相等)
4848
</details>
4949

5050
* <details>
5151
<summary>DOM相关处理</summary>
5252

53-
- [监听浏览器标签页的显示与隐藏](/Native-JavaScript/dom-handle.js)
53+
- [监听浏览器标签页的显示与隐藏](/Native-JavaScript/dom-handle.md#监听浏览器标签页的显示与隐藏)
54+
- [监听dom变化](/Native-JavaScript/dom-handle.md#监听dom变化)
5455
</details>
5556

56-
* [滚动条处理](/Native-JavaScript/scroll-handle.js)
57-
* [获取url的参数值,兼容search和hash](/Native-JavaScript/url-param.js)
58-
* [原生ajax封装](/Native-JavaScript/ajax.js)
59-
57+
* [滚动条处理](/Native-JavaScript/scroll-handle.md#滚动条位置处理)
58+
* [获取url的参数值,兼容search和hash](/Native-JavaScript/url-param.md#获取hash或者search参数值)
59+
* [原生ajax封装](/Native-JavaScript/ajax.md#ajax request)
60+
* [传入event则阻止冒泡](/Native-JavaScript/cancel-bubble.md#传入event则阻止冒泡)
6061

6162
> Vue 2
6263
* <details>
6364
<summary>Vue指令</summary>
6465
65-
- [点击元素外部关闭元素](/Vue/vue-directives/click-outside-to-close.js)
66-
- [图片懒加载](/Vue/vue-directives/lazy-load-image.js)
66+
- [点击元素外部关闭元素](/Vue/vue-directives/click-outside-to-close.md#点击当前区块元素外部关闭当前区块元素)
67+
- [图片懒加载](/Vue/vue-directives/lazy-load-image.md#使用交叉观察器(intersectionObserver)进行图片懒加载)
6768
</details>
6869

6970
* <details>
7071
<summary>Vue过滤器</summary>
7172
72-
- [时间格式化](/Vue/vue-filter/time-format.js)
73+
- [时间格式化](/Vue/vue-filter/time-format.md#时间格式化)
7374
</details>
7475

Vue/vue-directives/click-outside-to-close.js Vue/vue-directives/click-outside-to-close.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### 点击当前区块元素外部关闭当前区块元素
2+
````js
13
/**
24
* @function 点击当前区块元素外部关闭当前区块元素
35
* @example
@@ -59,4 +61,4 @@ export const clickOutsideToClose = {
5961
delete el.__vueClickOutsideClose__
6062
}
6163
}
62-
64+
````

Vue/vue-directives/lazy-load-image.js Vue/vue-directives/lazy-load-image.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### 使用交叉观察器(intersectionObserver)进行图片懒加载
2+
````js
13
/**
24
* @function 使用交叉观察器(intersectionObserver)进行图片懒加载
35
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/IntersectionObserver
@@ -44,4 +46,5 @@ export const layzLoadImg = {
4446
unbind (el, binding) {
4547

4648
}
47-
}
49+
}
50+
````

Vue/vue-filter/time-format.js Vue/vue-filter/time-format.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
###### 时间格式化
2+
3+
````js
14
const REGEX = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/
25
/**
36
* @function format time
@@ -46,3 +49,4 @@ export const formatTime = (val, format) => {
4649
return '--'
4750
}
4851
}
52+
````

0 commit comments

Comments
 (0)