preface
In daily development, the repeated click of the button is often ignored, and the result is that the careful test girl clicks the button to test abnormal, hahaha.
So how do we implement the repeated submission of buttons?
To get down to business:
First, we set a switch. When the button is clicked, we turn it off immediately and wait for the program to finish. If you need to click on it later, just release it again
In the code
let switch = false;
doSomething() {
if (switch) {
return false;
}
switch = true;
promise().then(res= > {
switch = false;
}).catch((a)= > {
switch = false;
});
}
Copy the code
This completes a switch; Only one interface can be invoked each time a button is clicked; Click until the interface responds.
If there is a better way, welcome to communicate
❤️ Watch two things
If you find this article inspiring, I’d like to invite you to do me two small favors:
- Click “like” and share this content with your QQ/ wechat group so that more people can see it.
- Pay attention to the public number “IT Flathead brother Alliance”, progress together, grow together!
- More articles
- Be asked 99.6% of Vue interview questions
- What kind of resume is the interviewer looking for?
- Is there anything special about JavaScript arrays
www.javascriptC.com is a platform dedicated to helping developers change the world with code. You can find the top content in the technology world here every day