更新时间:2022-06-09 08:32:33
使用$ for jQuery是完全安全的,它是jQuery的成语,at至少在你自己控制的页面上。
It's perfectly safe to use the $ for jQuery, it's the jQuery idiom, at least on your own pages which you control.
如果你确实选择在小部件中使用jQuery,你可以用一种方式来构建它以防止它发生冲突。
If you do choose to use jQuery in widgets you can structure it in a way that prevents it from conflicts.
一般来说,jQuery绑定到$和jQuery,所以单独使用jQuery并不能保证你的安全..
In general jQuery binds to both $ and jQuery so using jQuery alone does not guarantee you safey..
如果你担心的话与jQuery冲突确实暴露了$ .noConflit();
http://api.jquery.com/jQuery.noConflict/
If you are concerned with conflict jQuery does expose the $.noConflit(); http://api.jquery.com/jQuery.noConflict/
放弃对$的控制,你可以将jQuery存储在你选择的变量中(或者使用jQuery)。
Which relinquishes the control of $ and you can store jQuery in a variable of your choice (or use jQuery).
Here are the libraries that use the $ sign based on the Wikipedia page and this *** answer:
扫描此页面时,唯一想到的是:
Scanning this page, the only ones that come to mind are:
然而,jQuery以约90%的市场份额杀死它。
However jQuery is killing it with about 90% market share..