繁体   English   中英

NPM 引导轮播未捕获类型错误:超级表达式必须是 null 或 function 引导

[英]NPM Bootstrap Carousel Uncaught TypeError: Super expression must either be null or a function bootstrap

为 WordPress 主题使用 Bootstrap 的 NPM 构建(带有 Gulp),我不完全确定会出现什么问题。 Bootstrap 的新手,WordPress 或 Gulp(以前使用的 Foundation)不是新手。

这是我包含引导文件的方式,

// Set path to Bootstrap files
const BOOTSTRAP = 'node_modules/bootstrap';

// Select Bootstrap components, remove components project will not use
const SOURCE = {
    scripts: [

        // Bootstrap core 
        BOOTSTRAP + '/dist/js/bootstrap.js',

        // Pick the components you need in your project
        BOOTSTRAP + '/js/dist/carousel.js',

        // Place custom JS here, files will be concatenated
        'assets/scripts/js/**/*.js'
        ],

    // SCSS files will be concatenated
    styles: ['assets/styles/scss/**/*.scss'],
};

我的轮播标记,

<?php
    $testimonial_args = array(
        'post_type' => 'testimonial',
    );
    $testimonial_query =  new WP_Query( $testimonial_args );
?>
<div id="testimonial-carousel" class="carousel slide" data-ride="carousel">
    <div class="carousel-inner">
<?php
    $testimonial_integer = 0;
    if ( $testimonial_query->have_posts() ) :
    while ( $testimonial_query->have_posts() ) : $testimonial_query->the_post(); $testimonial_integer++;?>
        <div class="carousel-item <?php if ( 1 === $testimonial_integer ) { echo 'active'; } ?>">
            <?php the_title(); ?>
            <?php echo get_field('position'); ?>
            <?php echo get_field('city_state'); ?>
            <?php the_content(); ?>
        </div>
    <?php
    endwhile;
    wp_reset_postdata();
    endif;
    ?>
    </div>
    <a class="carousel-control-prev" href="#testimonial-carousel" role="button" data-slide="prev">
        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
    </a>
    <a class="carousel-control-next" href="#testimonial-carousel" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>

这里没有发生什么疯狂的事情,但是我抛出了这个控制台错误,

scripts.js?ver=5.8.3:1 Uncaught TypeError: Super expression must either be null or a function
    at _inherits (scripts.js?ver=5.8.3:1:6106)
    at scripts.js?ver=5.8.3:1:77341
    at scripts.js?ver=5.8.3:1:84943
    at scripts.js?ver=5.8.3:1:76256
    at scripts.js?ver=5.8.3:1:76312

仅当我包含轮播 JS 文件时才会出现该错误。 但是,看起来该错误实际上并不在该 JS 文件中。

我读了另一个答案,声称修复程序是较新版本的 Bootstrap,但带有 NPM 我应该有最新的,我什至运行npm update

我觉得我没有包含我需要的其他一些 JS 文件但是......??

正在使用 5.1.3 但降级到 4.6.1(其中有 util.js 文件,5.1.3 出于某种原因没有??)。 在包含 carousel 之前包含 util.js 文件,它就像一个魅力!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM