In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how vue uses setTimeout instead of setInterval. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Use setTimeout instead of setInterval
In general, we do not recommend using setInterval in the project, because it will have the phenomenon that the execution interval of the code is smaller than expected and "lose frames" because of its own implementation logic. Many people will think that the role of the second time parameter in setInterval is to execute the callback method after that millisecond, but in fact, its real effect is to put the callback method into the queue after that millisecond, but if there is a method being executed in the queue, it will wait for the previous method to finish, and if there is a code instance that has not been executed, it will not be inserted into the queue, resulting in "lost frames".
This is not the case with setTimeout, because each call generates a new timer, and no new timer code is inserted into the queue until the previous timer code has been executed.
/ / the timer will actually trigger the next callback setInterval immediately after 3 seconds (() = > {/ / it takes 2s}, 1000) to execute the code here; / / use setTimeout to rewrite, and trigger the next callback let doSometing = () = > {/ / it takes 2s setTimeout (doSometing, 1000);} doSometing () to execute the code here in 4 seconds. Thank you for reading! This is the end of the article on "how vue uses setTimeout instead of setInterval". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.