Original link: https://chegva.com/5465.html
When debugging the front-end recently, I found that when creating and editing, a quick click will cause the interface to be called multiple times in an instant, and it is necessary to perform an anti-shake operation on the front-end. Specifically, when the form point is saved, the operation method is debounced, and the debounced (anti-shake) function in lodash is used.
<xx-btn type="primary" :size="size" @click.native="handleSubmit">Save</xx-btn> ---- handleSubmit: debounce(function (e) { e.preventDefault(); this.form.validateFields((err, values) => { if (!err) { // console.log('Form data before processing', values); const queryParams = this.handleParams(values); this.$emit('change', queryParams); } }); }, 2000, { 'leading': true, 'trailing': false }),
refer to:
-
Vue (preventReClick) riot point + debounce and throttle functions
-
Vue uses lodash Debounce for anti-shake to control the frequency of high-consuming tasks
This article is reprinted from: https://chegva.com/5465.html
This site is for inclusion only, and the copyright belongs to the original author.