有没有办法让物化轮播与Django一起使用?我已经尝试过使用JQuery和其他示例,但是在Web检查器中查看网站时我无法使其工作,图像在资源中并且具有有效的链接,但它们并未显示在页面上(请注意文章.getID导致href为#1,!#2 !,依此类推,循环中有多少个图像)
<head>
{% load static %}
<!-- Compiled and minified CSS -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"
/>
<!-- Compiled and minified JavaScript -->
</head>
<body>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/js/materialize.min.js"></script>
<h1>POSTSSS</h1>
<div class="carousel carousel-slider center">
{% for post in object_list %}
<a class= "carousel-item" href="{{post.getID}}"><img src="{{post.cover.url }}" alt="{{post.title}}" /></a>
{% endfor %}
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.carousel');
var instances = M.Carousel.init(elems, options);
});
</script>
</body>
谢谢!