注册脚本难题注册wp_→_SCRIPT

时间:2017-09-26 作者:The WP Intermediate

wp_register_script( $handle, $src, $deps, $ver, $in_footer );
如果$ver 不需要,那么我们是否应该将该空间留空?还是完全删除逗号?

实例→

wp_register_script( \'scroll\', get_template_directory_uri() . \'/js/infinite-scroll.pkgd.min.js\', array( \'jquery\' ), \'1.1\', true );
对JQuery没有依赖性。这需要完全删除:

, array( \'jquery\' ),
或者像这样空白→

    wp_register_script( \'scroll\', get_template_directory_uri() . \'/js/infinite-scroll.pkgd.min.js\', , \'1.1\', true );

2 个回复
最合适的回答,由SO网友:Tom J Nowell 整理而成

只需传入null 或空的等效物。

例如,如果你不依赖任何东西,就说出来。它需要一个依赖项数组,所以传递一个空数组array()

或传入null

SO网友:David Lee

你不能让它空着,至少你必须放一个空字符串\'\', 它将默认依赖项为array() 和版本false:

wp_register_script( \'scroll\', get_template_directory_uri() . \'/js/infinite-scroll.pkgd.min.js\', \'\',\'\' , true );
为了便于阅读,您可以,并且它被广泛使用:

wp_register_script( \'scroll\', get_template_directory_uri() . \'/js/infinite-scroll.pkgd.min.js\', array(), null , true );
和我一样。

结束

相关推荐