vue-使用lodash庫進行函數(shù)限流
<template id="Application">
?<div>按鈕點擊{{count}}次</div>
?<button @click="click">按鈕</button>
</template>
<script>
import _ from 'lodash';
export default {
?name: "throttle",
?data(){
? ?return{
? ? ?throttle: false,
? ? ?count:0,
? ?}
?},
?methods:{
? ?// 因為input輸入時需要請求后臺,結果每次輸入一個字符都會請求,連續(xù)輸就連續(xù)請求 debounce防抖 延時500ms
? ?click:_.debounce(function () {
? ? ?this.count = this.count + 1
? ?}, 500)
?}
}
</script>
<style scoped>
</style>
標簽: