douzhe3516 2017-12-31 08:28
浏览 59
已采纳

版本4.9.1 wp排队脚本无法正常工作

I am using wordpress to add a cdn , this kind of thing works well with css with wp_styles . It seems to convert the link to the localhost link plus the cdn. My code echos:

http://tavlin.daniellowes.com/wp-content/plugins/home/aborigi6/public_html/tavlin/wp-content/themes/twentyseventeen/https:/cdnjs.cloudflare.com/ajax/libs/aos/2.2.0/aos.js?ver=1.1

It should echo
https:/cdnjs.cloudflare.com/ajax/libs/aos/2.2.0/aos.js?ver=1.1

Here is the problematic php code code:

function aos() { 

        wp_register_script( 'aos', 'https://cdnjs.cloudflare.com/ajax/libs/aos/2.2.0/aos.js', array('jquery'), 3.3, true); 
        wp_enqueue_script('aos'); 

    }

    add_action('wp_enqueue_scripts', 'aos');
  • 写回答

3条回答 默认 最新

  • duanpiyao2734 2017-12-31 18:00
    关注

    You can try this:

    <?php
    
    function aos() { 
        wp_register_script( 'aos', '//cdnjs.cloudflare.com/ajax/libs/aos/2.2.0/aos.js', array('jquery'), '3.3', true ); 
        wp_enqueue_script('aos'); 
    }
    add_action('wp_enqueue_scripts', 'aos');
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?