|
autoplay设置为:true,可以用鼠标滑动轮播,但是无法自动轮播,请大佬指教,下面是代码
<!-- HTML代码 -->
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide slide_item" style="background-color: #42b983">slider1</div>
<div class="swiper-slide slide_item" style="background-color: aqua">slider2</div>
<div class="swiper-slide slide_item" style="background-color: red">slider3</div>
</div>
</div>
<!-- 引入组件、样式 ->
import Swiper from 'swiper'
import 'swiper/swiper-bundle.min.css';
<!-- js代码 -->
mounted() {
setTimeout(()=>{
new Swiper(".swiper-container", {
autoplay: true,
speed: 800,
loop: true,
})
},300)
},
/* CSS样式 */
.swiper-container {
width: 600px;
height: 300px;
}
.slide_item {
width: 100%;
object-fit: cover;
height: 200px;
text-align: center;
font-size: 36px;
} |
|