更改第 3 方组件的 jQuery 命名空间

Change jQuery namespace of a 3rd party component

由于我们使用较旧的 jQuery 版本 (1.4) 和较新的版本 (1.11),因此我们为它们提供了 2 个不同的命名空间。 1.4 使用标准 $ 而 1.11 使用 jQuery1111.

现在正在尝试实现froala编辑器,需要使用1.11版本。我已将 froala 代码更改为此:

(function (a) {
    "function" == typeof define && define.amd ? define(["jquery"], a) : "object" == typeof module && module.exports ? module.exports = function (b, c) {
        return void 0 === c && (c = "undefined" != typeof window ? require("jquery") : require("jquery")(b)), a(c), c
    } : a(jQuery)
}(function (a) {

...

}(window.jQuery1111)));

但这给了我错误a is not a function(但脚本似乎可以运行)。错误出现在上面脚本的第 4 行。

如果我将第 4 行的 a(jQuery) 更改为 jQuery1111,它 运行 没有错误,但我不确定那是否正确,或者以后是否会导致错误上。

这是将第 3 方组件实施到非默认 jQuery 命名空间的正确方法吗?

更新:脚本顺序

里面<head />

<script src="/js/jquery.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    var jQuery1111 = jQuery.noConflict(true);
    window.jQuery1111 = window.jQuery1111 || jQuery1111;
</script>

里面<body />

<script type="text/javascript" src="/scripts/froala_editor.min.js"></script>

您可以更改脚本包含的顺序来解决问题,而无需修改第 3 方库

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/froala-editor/2.1.0/js/froala_editor.min.js"></script>
<script type="text/javascript">
  var jQuery1111 = jQuery.noConflict(true);
  window.jQuery1111 = window.jQuery1111 || jQuery1111;
</script>