【发布时间】:2022-01-19 01:26:02
【问题描述】:
将 Bootstrap 的 NPM 构建(带有 Gulp)用于 WordPress 主题,我不完全确定会出现什么问题。 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 文件但是...??
【问题讨论】:
标签: javascript twitter-bootstrap bootstrap-5