Interpretation of noConflict in jQuery

The source code of noConflict

The code location file is global.js under jq

Let me talk about the role and purpose of noConflict.

**
The role of the noConflict method is to cancel the pointing, because the pointing is cancelled in JQ, because in JQTake cancellation refers to , because as in J Q in is an alias JQ, and we may use other js library included in the actual development of jq, and these may also use the libraryas a variable of one of their exposed , And no C onflict is to solve this problem. By using no C onflict, we can cancel the variables exposed as one of them in JQ, and noConflict is to solve this problem. By using noConflict, we can cancel JQAs is his who 's a Yi a storm exposed out to the variable amount , while the n- O C O the n- f L i c t would be as a solution depends which one to ask questions . Pass through so that using n- O C O n- F L I C T , I can to take eliminate J QIn point.
**

Next, explain the structure of the code

**
In the source code, we can see that at the beginning of the code, the $sum jQueryattribute in the window will be assigned to the private variable $and jQuery, and then in the noConflict method, window.$ === jQuerythe judgment will first be judged to verify whether the jq is introduced in the project Renamed $, if renamed, then assign the new $value to window.$. Specifically, if you $use other js libraries in addition to JQ $, then I will give the location to other js libraries, $and finally return jQueryload JQ by letting you re-declare a variable name, instead of passing it $.
In the second judgment, deep && window.jQuery === jQueryit is to iterate the JQ version. Two different JQ versions may be used. If iteration is required, the deep value is true.
The following is the website address, you can understand by yourself, if the statement in this article is wrong, please
https://api.jquery.com/jquery.noconflict/

Guess you like

Origin blog.csdn.net/m0_38038767/article/details/110424083