我想知道在注册脚本并指定依赖项后,在将其排队时,您是否应该再次指定依赖项?
按照这个好的逻辑,我会说不,但我不知道......你的灯很感激!
实施例1
add_action( 'wp_enqueue_scripts', 'theme_scripts' );
function theme_scripts() {
if( ! is_admin() ) {
wp_register_script( 'script_one_js', '//path/to/script/one.js' );
wp_register_script( 'script_two_js', '//path/to/script/two.js', array( 'script_one_js' ) );
// Specifying dependency again
wp_enqueue_script( 'script_one_js' );
wp_enqueue_script( 'script_two_js', array( 'script_one_js' ) );
};
};
实施例2
add_action( 'wp_enqueue_scripts', 'theme_scripts' );
function theme_scripts() {
if( ! is_admin() ) {
wp_register_script( 'script_one_js', '//path/to/script/one.js' );
wp_register_script( 'script_two_js', '//path/to/script/two.js', array( 'script_one_js' ) );
// NOT specifying dependency again
wp_enqueue_script( 'script_one_js' );
wp_enqueue_script( 'script_two_js' );
};
};
达令说