# 截流防抖
# 截流
# throttle
- 示例代码:
 
<template>
    <div class="wrapper">
        <text>throttle: 截流函数</text>
    </div>
</template>
<script>
export default {
    data:()=> ({
        name: 'deepCopy',
    }),
    methods: {
        throttleHandler() {
            //函数截流
            let res = this.$util.throttle(()=> {
                this.$toast('hello, dolphinWeex !')
            },1000)
        }
    }
}
</script>
<style scoped>
.wrapper{
    background-color: #ffffff;
}
</style>
 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 参数
- 参数详情:
 
| Params | Type | Required | default | Value | 
|---|---|---|---|---|
func |  any |  Y |  - |  要执行的方法 | 
wait |  Number |  N |  500 |  延时的时间 | 
immediate |  Boolean |  N |  true |  是否立即执行 | 
# 防抖
# debounce
- 示例代码:
 
<template>
    <div class="wrapper">
        <text>debounce: 防抖</text>
    </div>
</template>
<script>
export default {
    data:()=> ({
        name: 'debounce',
    }),
    methods: {
        debounceHandler() {
            //函数截流
            let res = this.$util.debounce(()=> {
                this.$toast('hello, dolphinWeex !')
            },1000)
        }
    }
}
</script>
<style scoped>
.wrapper{
    background-color: #ffffff;
}
</style>
 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 参数
- 参数详情:
 
| Params | Type | Required | default | Value | 
|---|---|---|---|---|
func |  any |  Y |  - |  要执行的方法 | 
wait |  Number |  N |  500 |  延时的时间 | 
immediate |  Boolean |  N |  true |  是否立即执行 |