jQuery.noConflict()后怎么恢复?

jQuery.noConflict() 运行这个函数将变量$的控制权让渡给第一个实现它的那个库。

但有的时候我们用过别的库后,需要再恢复到用jQuery的状态。其实恢复的方法非常简单。

一句话 window.$=jQuery

注意:这只符合noConflict() 的情况,不适合于用jQuery.noConfilct(true)的情况。因为当给noConflict()加参数true的时候,连jQuery这个名字都不能用了。

jQuery.noConfilct(true)后再想恢复的方式:

var a = jQuery.noConflict(true);
//其它库的代码
window.$ =window.jQuery = a;


( ! ) Warning: Missing argument 1 for cwppos_show_review(), called in /data/www/enjoyphp/wp-content/themes/flat/content-single.php on line 29 and defined in /data/www/enjoyphp/wp-content/plugins/wp-product-review/includes/legacy.php on line 18
Call Stack
#TimeMemoryFunctionLocation
10.0000355208{main}( ).../index.php:0
20.0001355496require( '/data/www/enjoyphp/wp-blog-header.php' ).../index.php:17
30.173810152600require_once( '/data/www/enjoyphp/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.175710223744include( '/data/www/enjoyphp/wp-content/themes/flat/single.php' ).../template-loader.php:74
50.260910780600get_template_part( ).../single.php:5
60.260910781120locate_template( ).../general-template.php:167
70.260910781216load_template( ).../template.php:643
80.260910781600require( '/data/www/enjoyphp/wp-content/themes/flat/content-single.php' ).../template.php:686
90.265310766336cwppos_show_review( ).../content-single.php:29

发表评论

电子邮件地址不会被公开。 必填项已用*标注