Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript WordPress JS在引导和Popper中的加载问题_Javascript_Jquery_Wordpress_Popper.js - Fatal编程技术网

Javascript WordPress JS在引导和Popper中的加载问题

Javascript WordPress JS在引导和Popper中的加载问题,javascript,jquery,wordpress,popper.js,Javascript,Jquery,Wordpress,Popper.js,脚本在加载时似乎出现了一些奇怪的问题。我有这个: function fyxt_custom_scripts() { wp_enqueue_script('jquery'); //load order is important (from website jquery, popper, bootstrap) wp_register_script('prefix_bootstrap', '//stackpath.bootstrapcdn.com/bootstrap/4.3.1

脚本在加载时似乎出现了一些奇怪的问题。我有这个:

function fyxt_custom_scripts() {
    wp_enqueue_script('jquery');
    //load order is important (from website jquery, popper, bootstrap)
    wp_register_script('prefix_bootstrap', '//stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js', array( 'jquery' ),'',true );
    wp_enqueue_script('prefix_bootstrap');
}
add_action( 'wp_enqueue_scripts', 'fyxt_custom_scripts' );
我收到以下控制台错误:

未捕获类型错误:引导的工具提示需要Popper.js

因此,我在WordPress中添加了以下内容,让popper进入其中

    function fyxt_custom_scripts() {
        wp_enqueue_script('jquery');
        //popper for bootstrap
        wp_register_script( 'popper','https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js', array( 'jquery' ),'',true );
        wp_enqueue_script( 'popper' );
        //load order is important (from website jquery, popper, bootstrap)
        wp_register_script('prefix_bootstrap', '//stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js', array( 'jquery' ),'',true );
        wp_enqueue_script('prefix_bootstrap');
    }
    add_action( 'wp_enqueue_scripts', 'fyxt_custom_scripts' );
一旦装进去,就把波普尔装进去。但现在我又犯了一个错误。知道为什么吗

tooltip.js:559 Uncaught TypeError: this.element.getAttribute is not a function
    at i.t._fixTitle (tooltip.js:559)
    at i.t._setListeners (tooltip.js:554)
    at new i (tooltip.js:142)
    at i.t._enter (tooltip.js:576)
    at HTMLDocument.<anonymous> (tooltip.js:528)
    at HTMLDocument.handle (jquery.js?ver=1.12.4-wp:3)
    at HTMLDocument.dispatch (jquery.js?ver=1.12.4-wp:3)
    at HTMLDocument.r.handle (jquery.js?ver=1.12.4-wp:3)
如果包含了“tabs脚本”,我就得到了错误,jquery按钮都被破坏了。制表符和手风琴很管用

tooltip.js:568 Uncaught TypeError: this.element.getAttribute is not a function
    at i.t._fixTitle (tooltip.js:568)
    at i.t._setListeners (tooltip.js:563)
    at new i (tooltip.js:140)
    at HTMLDocument.<anonymous> (tooltip.js:767)
    at Function.each (jquery.js?ver=1.12.4-wp:2)
    at a.fn.init.each (jquery.js?ver=1.12.4-wp:2)
    at a.fn.init.i._jQueryInterface [as tooltip] (tooltip.js:758)
    at HTMLDocument.<anonymous> (tabs.js?ver=ec6af3c620057499034adb106af5aae1:10)
    at i (jquery.js?ver=1.12.4-wp:2)
    at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4-wp:2)
    at Function.ready (jquery.js?ver=1.12.4-wp:2)
    at HTMLDocument.J (jquery.js?ver=1.12.4-wp:2)

我不太熟悉加载顺序和依赖关系,所以这里的建议非常有用。非常感谢你的帮助

您应该将所有JS脚本移动到页脚中。我希望它能帮助你。请看下面:

函数fyxt_自定义_脚本{ }
添加_操作“wp_页脚”、“fyxt_自定义_脚本” 我所做的是尊重Bootstrap提供给我的URL:

然后在我的函数中,我只包含我需要的引用:

function fyxt_custom_scripts(){
    wp_register_style(('prefix_bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css', array(), '4.4.1', 'all');


    wp_register_script('popper', 'https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js', array( 'jquery' ),'1.16.0', true );


    wp_register_script('prefix_bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js', array( 'jquery', 'popper' ),'4.4.1', true );
}
add_action( 'wp_enqueue_scripts', 'fyxt_custom_scripts' );
我遵循引导程序的建议,并将脚本调用放在页脚中。 在那之后,确保您有对函数的调用
在。。。HTML标签和HTML标签之前的标签分别出现在主题中。

似乎是PLUpload导致了这些问题。我尝试了许多不同的配置和加载顺序,但它似乎总是与plupload发生冲突。我决定不使用它,而是使用另一个类似的插件Dropzone。PLupload已经有几年没有更新了,所以我认为还是选择最近更新的/现代风格为好。谢谢大家的提示和建议

尝试更改jQuery的版本,我的意思是删除wordpress提供的现有jQuery并从CDN加载它。我更新到了最新版本,但它没有修复它,仍然会出错。它们仍然会导致错误。我想装货单或是什么东西把这些搞乱了。我在我知道的地方添加了依赖项,但不确定是否需要添加更多。您还应该禁用它在function.php或footer.php中调用的每个js文件,然后逐个禁用,并检查哪些js冲突。这可能会有帮助。
jquery.ui.plupload.min.js?ver=ec6af3c620057499034adb106af5aae1:1 Uncaught TypeError: i.widget is not a function
    at jquery.ui.plupload.min.js?ver=ec6af3c620057499034adb106af5aae1:1
    at jquery.ui.plupload.min.js?ver=ec6af3c620057499034adb106af5aae1:1
function fyxt_custom_scripts(){
    wp_register_style(('prefix_bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css', array(), '4.4.1', 'all');


    wp_register_script('popper', 'https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js', array( 'jquery' ),'1.16.0', true );


    wp_register_script('prefix_bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js', array( 'jquery', 'popper' ),'4.4.1', true );
}
add_action( 'wp_enqueue_scripts', 'fyxt_custom_scripts' );