mootools.js可以和microsoftajax.js一起使用吗?

Can mootools.js work with microsoftajax.js?

本文关键字:js 一起 microsoftajax mootools      更新时间:2023-09-26

在一个页面上有mootools.js和microsoftajax.js脚本。基本上我使用microsoftajax.js,所以我可以在脚本中使用类和委托等。Mootools由客户在其代码中使用。看起来它们不能在一起因为我得到了Type.createDelegate is not a function错误。有解决办法吗?

更新:在我的脚本中抛出错误(脚本使用microsoftajax.js)Mootools 1.3.2版本

Type是MooTools的一个构造,对于定义核心中的许多东西至关重要,包括类、对象、函数、数组、数字、字符串、日期、表(哈希)等。

作为构造函数存在于全局对象中:https://github.com/mootools/mootools-core/blob/master/Source/Core/Core.js L148

and的用法如下(例如):https://github.com/mootools/mootools-core/blob/master/Source/Class/Class.js由于

无论如何,对于OP来说,Type用于什么并不重要。关键是,如果mootools在其他脚本之后加载,它覆盖Type。另一方面,如果您在脚本之前加载它,并且不需要创建一个新的mootools Type,事情可能就没问题了。

你总是可以保存对它的引用,并在以后恢复它。

,

var MooTools.Type = this.Type;
... load ms one.
... do stuff with `Type.createDelegate` etc
... restore mootools one:
this.Type = MooTools.Type;

注。与microsoftajax.js,为什么你不能使用mootools请求类代替?