我一直在搜索数小时,也试图从这里寻求帮助,但是找不到更早的解决方案。您能否向我解释一下,为什么在django项目中实现js代码时会引发诸如未解决的函数或方法carousel()的问题。在上下文操作中,它告诉:引入局部变量。我该怎么办?!请帮忙!
$(document).ready(function() {
$(".carousel").carousel();
});
.carousel {
position: absolute;
height: 250px;
left:400px;
perspective:175px;
}
.carousel .carousel-item {
width: 150px;
}
.carousel .carousel-item img {
width: 100%;
border-radius: 10px 10px 0 0;
}
.carousel .carousel-item h2 {
margin: -5px 0 0;
background: white;
color: red;
box-sizing: border-box;
padding: 10px 5px;
font-weight: bold;
font-size: 1em;
text-align: center;
}
{% load static %}
<html lang="">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"/>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="/Main/static/functionality/imageslider.js"></script>
<link rel="stylesheet" href="/Main/static/blog/imageslider.css" />
<title></title>
</head>
<body>
<div class="carousel">
<a class="carousel-item" href="#"
><img src="/media/carousel-pics/photo-1454942901704-3c44c11b2ad1.jpg" alt="">
<h2>3D CAROUSEL</h2>
</a>
<a class="carousel-item" href="#"
><img src="/media/carousel-pics/photo-1454942901704-3c44c11b2ad1.jpg" alt="" />
<h2>3D CAROUSEL</h2>
</a>
<a class="carousel-item" href="#"
><img src="/media/carousel-pics/photo-1454942901704-3c44c11b2ad1.jpg" alt=""/>
<h2>3D CAROUSEL</h2>
</a>
<a class="carousel-item" href="#"
><img
src="/media/carousel-pics/photo-1454942901704-3c44c11b2ad1.jpg"
alt=""/>
<h2>3D CAROUSEL</h2>
</a>
</div>
</body>
</html>