Description of the consequences of repeated binding events in javascript
Recently, I am modifying the open source stuff on Baidu Maps and want to split the code that is coupled together. After disassembly, some problems were found. When there is no logical problem, the effect that should appear does not appear. Then I thought the code was written incorrectly, so I kept searching for it. During debugging, it was found that the corresponding event was executed twice. I immediately understood that the event must have been repeatedly bound to somewhere. Sure enough, I was really stupid and bound to two incidents.
When writing code, if you find that the bound event has been fired twice, you need to check whether it has bound two events. Don't just check where the code is everywhere, or suspect that there is something wrong with other people's API.
This article only records the problems I encountered during development. The recently modified open source things from Baidu Map will be presented to everyone after the project is released. I am a rookie, I hope everyone will give me some advice.
In the future, everyone will pay more attention during the development process.
Related Articles
js getBoundingClientRect() to get the location of the page element
This method is no longer IE Only. FF3.0+ and Opera9.5+ have supported this method. It can be said that the efficiency can be greatly improved in obtaining page element positions. In previous versions of Opera and Firefox, the absolute position of elements in the page must be obtained by looping.2010-11-11Detailed explanation of the execution time of the asynchronous function record
In this article, I will implement a reusable function to handle JavaScript delayed asynchronous operations. Friends in need can refer to it, let’s take a look together below.2016-08-08JavaScript implements page selection or reverse selection with one click
This article mainly introduces the JavaScript implementation page to you in detail. The sample code in the article is introduced in detail and has certain reference value. Interested friends can refer to it.2022-07-07js implement form automatic completion function
2008-02-02WeChat applet implementation message board
This article mainly introduces the message board for WeChat mini-program implementation, which has certain reference value. Interested friends can refer to it.2018-10-10Component design specifications for WeChat mini program development
This article mainly introduces relevant information about the component design specifications for WeChat mini program development. It is quite helpful to students who are just getting started with WeChat mini program. Friends who need it can refer to it.2021-05-05How to change the font size of an article
This article mainly introduces how to change the font size of articles by js. When you use word documents, the toolbar provides you with options to change the font size. How does js change the font size of articles? The following is revealed to you. Friends who need it can refer to it.2016-01-01JS implementation of drag modal box case
This article mainly introduces the JS implementation of drag mode box cases for you in detail. The sample code in the article is introduced in detail and has certain reference value. Interested friends can refer to it.2022-07-07Summary of solutions to slow webpack packaging speed
This article mainly introduces a summary of solutions to completely solve the slow packaging of webpack. It introduces 3 methods in detail. If you are interested, you can learn about it.2017-07-07Method to access name collection object through getElementsByName in js
Below, the editor will bring you a method to access the name collection object through getElementsByName in js. The editor thinks it is quite good, so I will share it with you now and give you a reference. Let's take a look with the editor2016-10-10