截流防抖
#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>
| 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>
| Params |
Type |
Required |
default |
Value |
func |
any |
Y |
- |
要执行的方法 |
wait |
Number |
N |
500 |
延时的时间 |
immediate |
Boolean |
N |
true |
是否立即执行 |