在我看来,最好将样式与脚本和其他资产分开。这起到了作用:
function my_theme_enqueue_styles() {
wp_enqueue_style( \'parent-style\', get_parent_theme_file_uri() . \'style.css\' );
}
add_action( \'my_theme_enqueue_styles\', \'wp_enqueue_styles\' );
function my_theme_enqueue_assets() {
wp_enqueue_script( \'behavior\', get_theme_file_uri( \'behavior.js\' ), array(), null, true );
}
add_action( \'wp_enqueue_scripts\', \'my_theme_enqueue_assets\' );