如果您只想在插件菜单页面中使用引导。使用$hook = add_menu_page()
而不是add_menu_page()
. 并使用该挂钩加载任何样式和脚本
add_action( \'admin_menu\', \'register_page\');
function register_page()
{
$my_hook = add_menu_page( \'tab title\', \'page title\', \'manage_options\', \'my-page-slug\', \'callback_function\', \'dashicons-cloud\', 1 );
add_action( \'load-\'.$my_hook, load_scripts );
}
function load_scripts ()
{
add_action( \'admin_enqueue_scripts\', \'enqueue_bootstrap\' );
}
function enqueue_bootstrap()
{
$path = plugins_url( \'my_plugin/inc/css/bootstrap.min.css\' ); //use your path of course
$dependencies = array(); //add any depencdencies in array
$version = false; //or use a version int or string
wp_enqueue_style( \'myplugin-bootstrap\', $path, $dependencies, $version );
}