问题
这是我的代码:
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
- </head>
- <body>
- <div class="carousel carousel-slider center" data-indicators="true">
- <div class="carousel-fixed-item center">
- <a class="btn waves-effect white grey-text darken-text-2">button</a>
- </div>
- <div class="carousel-item red white-text" href="#one!">
- <h2>First Panel</h2>
- <p class="white-text">This is your first panel</p>
- </div>
- <div class="carousel-item amber white-text" href="#two!">
- <h2>Second Panel</h2>
- <p class="white-text">This is your second panel</p>
- </div>
- <div class="carousel-item green white-text" href="#three!">
- <h2>Third Panel</h2>
- <p class="white-text">This is your third panel</p>
- </div>
- <div class="carousel-item blue white-text" href="#four!">
- <h2>Fourth Panel</h2>
- <p class="white-text">This is your fourth panel</p>
- </div>
- </div>
- <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
- <script>
- $(document).ready(function () {
- $('.carousel.carousel-slider').carousel({ fullWidth: true });
- });
- </script>
- </body>
- </html>
复制代码
它基本上是官方文档的复制粘贴,它在我的桌面上运行良好,但在移动设备上运行良好(我在 Android 上)。轮播正在显示,但是当我滑动它时没有任何反应。
官方文档页面 http://materialecss.com/carousel.html 中的示例轮播在我的移动设备上运行良好。
回答
我认为您使用的是旧的 jquery 版本。尝试使用 jquery-3.2.1
|