我看到 jQuery UI Touch Puch 的起始行是这样的:
(function ($) {
// Detect touch support
$.support.touch = 'ontouchend' in document;
最后一行是这样的:
})(jQuery);
这是否意味着这段代码中的美元符号是别名?我们遇到了在同一页面上运行不同版本的 jQuery 的问题(Adobe Edge 动画需要旧版本,而我们的应用程序从新版本执行最新/最大的拖放操作)。我们希望开始将代码别名为不同的变量,并希望确保涵盖所有版本。该库是否已使用别名?
最佳答案
(function (jQ) { // this is a reference to jQuery, see last line
// Detect touch support
jQ.support.touch = 'ontouchend' in document;// but than use your reference inside your fn
})(jQuery);
或使用jQuery.noConflict()
:
jQuery.noConflict();
(function ($) { // remap '$' to 'jQuery' (see last line)
// Detect touch support
$.support.touch = 'ontouchend' in document;// use '$' freely
})(jQuery);
关于jquery - jQuery UI Touch 库是否有别名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11694417/