gpt4 book ai didi

javascript - Twitter bootstrap carousel 无法正常工作(symfony2 项目)

转载 作者:行者123 更新时间:2023-11-30 07:16:41 24 4
gpt4 key购买 nike

加载页面时,我的控制台显示:

                $('.carousel').carousel is not a function

生成的 html 源代码(我使用 symfony 和 twig 文件)如下所示:

<body>        

<div class="container">
<div class="row">
<div class="span6 well">
<div id="myCarousel" class="carousel">
<!-- Carousel items -->
<div class="carousel-inner">
<div class="active item"><img alt="" src="/projet_etienne_auth/web/bundles/etiennepsav/images/carousel1.jpg"></div>
<div class="item"><img alt="" src="/projet_etienne_auth/web/bundles/etiennepsav/images/carousel2.jpg"></div>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
</div>
</div>
</div>
</div>


<!-- Le javascript
================================================== -->

<script rel="javascript" href="/projet_etienne_auth/web/bundles/etiennepsav/js/bootstrap.js" type="text/javascript" media="all" ></script>
<script rel="javascript" href="/projet_etienne_auth/web/bundles/etiennepsav/js/jquery-1.8.3.js" type="text/javascript" media="all" ></script>
<script rel="javascript" href="/projet_etienne_auth/web/bundles/etiennepsav/js/bootstrap-carousel.js" type="text/javascript" media="all" ></script>
<script rel="javascript" href="/projet_etienne_auth/web/bundles/etiennepsav/js/bootstrap-transition.js" type="text/javascript" media="all" ></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
$('.carousel').carousel() ;
});

</script>

有人会发现哪里出了问题吗?干杯

最佳答案

将最后的 javascript 更改为以下内容..

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script rel="javascript" href="/projet_etienne_auth/web/bundles/etiennepsav/js/bootstrap.js" type="text/javascript" media="all" ></script>
<script type="text/javascript">
$(document).ready(function() {
$('.carousel').carousel();
});
</script>

jquery 库需要是包含的第一个脚本文件,然后是 bootstrap.js 文件。

如果您没有将它们全部包含在 Bootstrap 下载包中,则只包含以下脚本文件..

<script rel="javascript" href="/projet_etienne_auth/web/bundles/etiennepsav/js/bootstrap-transition.js" type="text/javascript" media="all" ></script> 
<script rel="javascript" href="/projet_etienne_auth/web/bundles/etiennepsav/js/bootstrap-carousel.js" type="text/javascript" media="all" ></script>

关于javascript - Twitter bootstrap carousel 无法正常工作(symfony2 项目),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13596703/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com