cdn工作正常,但入队不起作用

时间:2018-06-01 11:47:29

标签: javascript php jquery wordpress

我正在尝试在代码中包含jquery库,我这样做了:

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.11.4/jquery-ui.js"></script>

这非常好用,我得到了我需要的东西,但后来我尝试将wordpress的预装jquery库排入队列:

function my_switchbutton_function(){
    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('jquery-effects-core');
}
add_action('admin_enqueue_scripts', 'my_switchbutton_function');

但这不起作用我不知道为什么......我也需要排队风格? 版本控制在cdn和preloaded js中都是1.11.4

是否还有其他任何需要排队的脚本?

3 个答案:

答案 0 :(得分:0)

您需要在函数

中定义js文件路径

示例:

loadOptions := ini.LoadOptions{}
loadOptions.UnparseableSections = []string{"vm_master", "vm_client"}

nodeConfig, err := ini.LoadSources(loadOptions, inventoryFilePath)

如果您使用的是子主题且文件路径位于子主题中,则将get_template_directory_uri替换为get_stylesheet_directory_uri

答案 1 :(得分:0)

试试这个

       add_action('wp_enqueue_scripts', 'myjs'); // add at front side
       add_action('admin_enqueue_scripts', 'myjs'); // to add at admin side

       function myjs() {
         wp_enqueue_script('google-maps', '//ajax.aspnetcdn.com/ajax/jquery.ui/1.11.4/jquery-ui.js', array(), '3', true);
        }

答案 2 :(得分:0)

我希望这有助于解决您的问题

<?php
function twentyseventeen_child_enqueue_scripts() {
    wp_enqueue_script( 'jquery-js', get_stylesheet_directory_uri() . '/assets/css/jquery.min.js');
}
add_action( 'wp_enqueue_scripts', 'twentyseventeen_child_enqueue_scripts');
?>
相关问题