[英]Parcel / ES6: Bootstrap function not working
I'm new to ES6 / Node Modules / Parcel but so far everything worked fine, but as I can see the Bootstrap functions aren't working.我是 ES6 / Node Modules / Parcel 的新手,但到目前为止一切正常,但我可以看到 Bootstrap 功能不起作用。
Here's the part of the code that throws errors:这是引发错误的代码部分:
import 'typeface-montserrat'
import jquery from "jquery";
export default (window.$ = window.jQuery = jquery);
import 'bootstrap';
import './css/main.scss';
if($('#news-carousel .carousel-item').length < 5)
{
//this function is not working
$('#news-carousel').carousel({
interval: false
});
}
//tested this too and it wont working either
$("#modalId").modal("show");
Error:错误:
Uncaught TypeError: $(...).carousel is not a function
Ok I figure it out how to handle this.好的,我弄清楚如何处理这个问题。
After many failed tests, this worked:经过多次失败的测试,这奏效了:
import 'typeface-montserrat'
import jquery from "jquery";
export default (window.$ = window.jQuery = jquery);
import 'bootstrap';
import './css/main.scss';
//import the proper classes from bootstrap
import { Carousel, Modal } from 'bootstrap';
//handle the Carousel configuration, in this I wanted to stop the slides
new Carousel($('#news-carousel')[0], {
interval: false
});
//initialize the Modal class
var modal = new Modal($('#modalId')[0]);
//show the modal
modal.show();
//hide the modal
modal.hide();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.