1.下载lodash包
2.导入
import _ from 'lodash'
2.语法
函数名:_.debounce(function(){处理的事件},时间)
3.防抖解决连续点击登陆问题
methods: {
handleLogin: _.debounce(function() {
this.$refs.loginForm.validate(async valid => {
if (valid) {
await this.$store.dispatch('user/login', this.loginForm).catch(() => {})
this.$router.push({ path: this.redirect || '/' })
} else {
console.log('error submit!!')
return false
}
})
}, 200)
}