vue-使用lodash库进行函数限流


(资料图)

<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输入时需要请求后台,结果每次输入一个字符都会请求,连续输就连续请求 debounce防抖 延时500ms    click:_.debounce(function () {      this.count = this.count + 1    }, 500)  }}</script><style scoped></style>

关键词:

为你推荐

新股
市场
Copyright@  2015-2022 大众证券网版权所有  备案号: 豫ICP备20014643号-14   联系邮箱: 905 14 41 07@qq.com