【发布时间】:2021-07-02 04:19:46
【问题描述】:
所以我下载了 bootstrap 5 库 - compiled css and js 和 source files。我已经尝试了这两种方法-据我所知,css加载得很好-但是,我无法让this example在boostrap 4上的相关帖子中工作,这应该适用于bootstrap 5 ...我正在尝试避免使用 CDN 来提供库,因此我下载了它们。当我使用示例中提供的 CDN 时,它就像一个魅力。
有人可以指出我在使旋转木马工作时缺少什么吗?我需要参考哪些文件才能使其滑动?
(这里有一些代码,所以我不会被骂)
我正在使用 dJango,当我检查控制台时,我没有资源错误。
再一次,当我使用 BS 4 CDN 时,一切正常......
{% load static %}
<html>
<head>
<title>
Welcome!
</title>
<!--
uncomment this and it works
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
the problem is the below
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
-->
<!--example:-->
<!--href="{% static 'polls/style.css' %}"-->
<!--theme-->
<link rel="shortcut icon" type="image/jpg" href="{% static 'favicon/CES.png' %}"/>
<link type="text/css" rel="stylesheet" href="{% static 'CSS/main.css' %}">
<!--jQuery-->
<script src="{% static 'Java/jQuery/jquery-3.6.0.js' %}"></script>
<script src="{% static 'Java/jQuery/jquery-3.6.0.min.js' %}"></script>
<script src="{% static 'Java/jQuery/jquery-3.6.0.slim.js' %}"></script>
<script src="{% static 'Java/jQuery/jquery-3.6.0.slim.min.js' %}"></script>
<!--<script src="https://code.jquery.com/jQuery/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>-->
<!--bootstrap related-->
<!--
<link type="text/css" rel="stylesheet" href="{% static 'Bootstrap/bootstrap-5.0.2-dist/css/bootstrap.min.css' %}">
<script src="{% static 'Bootstrap/bootstrap-5.0.2-dist/js/bootstrap.min.js' %}"></script>
<script src="{% static 'Bootstrap/bootstrap-5.0.2-dist/js/bootstrap.bundle.min.js' %}"></script>
-->
<link type="text/css" rel="stylesheet" href="{% static 'Bootstrap/bootstrap-5.0.2/dist/css/bootstrap.min.css' %}">
<script src="{% static 'Bootstrap/bootstrap-5.0.2/dist/js/bootstrap.bundle.js' %}"></script>
<script src="{% static 'Bootstrap/bootstrap-5.0.2/dist/js/bootstrap.bundle.min.js' %}"></script>
<script src="{% static 'Bootstrap/bootstrap-5.0.2/dist/js/bootstrap.js' %}"></script>
<script src="{% static 'Bootstrap/bootstrap-5.0.2/dist/js/bootstrap.min.js' %}"></script>
<!--
this is the problem...
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
-->
</head>
<body>
<!--Image Carosel-->
<div class="d-flex justify-content-center">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://placeimg.com/1080/500/animals" alt="First slide">
<div class="carousel-caption d-none d-md-block">
<h5>My Caption Title (1st Image)</h5>
<p>The whole caption will only show up if the screen is at least medium size.</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://placeimg.com/1080/500/arch" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://placeimg.com/1080/500/nature" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" 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="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</body>
</html>
我必须在早上睡觉和做事......我将在 12 小时后起床 - 所以不要着急。
【问题讨论】:
-
什么?看起来您正在加载 4 种不同的 jquery 变体和 4 种不同的 BS5 变体......我认为它们中的任何一个都没有实际加载。
-
@Vino 它们都已加载-我更改了代码示例中的路径(因此,如果您熟悉 django,它们看起来很奇怪-我有我的理由)尽管进行了更改,但控制台没有不要抛出任何错误。我拼命地试图解决这个问题,所以我包含了所有的 js 和 css 文件并将其缩小到 2 个导入。最后,Paolo Cava 的回答对我有用——我不知道这是在阅读“新功能”列表后对 BS 5 所做的更改。抱歉,我无法尽快回复您。
标签: javascript jquery cdn bootstrap-5