javascript - 哪些 JavaScript 框架相互冲突?

标签 javascript frameworks conflict

有时我想对某些事情使用 mootools,对其他事情使用 Prototype & script.aculo.us 但在同一个范围内地点。我什至考虑过添加其他人,但担心冲突。任何人都有经验,还是我只是想让事情对我自己来说太复杂了?

最佳答案

如果你真的、真的想这样做,那么你将能够没有太多问题 - 主要库被设计为在它们自己的命名空间内表现良好,有几个值得注意的异常(exception) - 来自 Using JQuery with Other Frameworks :

The jQuery library, and virtually all of its plugins are constrained within the jQuery namespace. As a general rule, "global" objects are stored inside the jQuery namespace as well, so you shouldn't get a clash between jQuery and any other library (like Prototype, MooTools, or YUI).

That said, there is one caveat: By default, jQuery uses "$" as a shortcut for "jQuery", which you can over-ride.

所以,是的,你可以做到,但你可能会为自己制造更麻烦的维护问题 - 框架功能之间的细微差别今天对你来说可能很明显,但 6 个月后回来,它可能是另一个故事!因此,我建议尽可能保持简单,并在代码库中使用尽可能少的不同框架(最好是 1 个!)。

关于javascript - 哪些 JavaScript 框架相互冲突?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/164403/

相关文章:

javascript - 从跨域在 Iframe 上应用样式

php - 使用两个同名的类

python - SVN钩子(Hook)脚本冲突

java - 使用 webdriver 检测远程计算机上的操作系统的包装类?

iOS:dyld:库未加载 SQLite

iphone - iOS CloudApp 集成

git::merge 来自本地和远程分支中不同文件夹的文件

javascript - 比较具有 2 个参数的列表

javascript - 如何更改字段属性: readonly and after change button to save

javascript - google+ 环聊 OnAir 按钮 Html 标签