douzhe3516 2017-12-31 08:28 采纳率: 0%
浏览 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');
  • 写回答

1条回答 默认 最新

  • dourui9570 2017-12-31 10:01
    关注

    try this:

    function wpdocs_theme_name_scripts() {
        wp_enqueue_script( 'aos', 'https://cdnjs.cloudflare.com/ajax/libs/aos/2.2.0/aos.js', array('jquery'), 3.3, true); 
    
    }
    add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
    
    评论

报告相同问题?