下载Lodash在项目中
num i lodash
新建uniapp页面
<template>
<view @click="ban(1)">//触发节流
<text>点击触发lodash节流方法</text>
</view>
</template>
<script>
import lodash from 'lodash';//引入lodash
methods:{
ban:lodash.throttle(function(id){
console.log(id,'传参');
this.ban2(); //触发第二个方法
},5000),
ban2(){
console.log('我是ban2方法')
}
}
</script>