使用以下方法,使用单个操作挂钩将脚本排队:
/**
* Proper way to enqueue scripts.
* The same approach can be used to enqueue styles.
*/
function my_interface_enqueues() {
wp_enqueue_script( \'require-js\', plugin_dir_url( __FILE__ ) . \'js/libs/requirejs/require.js\', array(), \'1.0.0\', true );
wp_enqueue_script( \'main-js\', plugin_dir_url( __FILE__ ) . \'js/main.js\', array(), \'1.0.0\', true );
// Here, a sample stylesheet enqueued.
wp_enqueue_style( \'style-name\', get_stylesheet_uri() );
}
add_action( \'wp_enqueue_scripts\', \'my_interface_enqueues\' );
这肯定行得通。