在我還沒接觸到微信小程序之前,通常使用輪播要么手寫或使用swiper插件去實(shí)現(xiàn),當(dāng)我接觸到微信小程序之后,我看到了微信小程序的強(qiáng)大之處,讓我為大家介紹一下吧!
swiper與swiper-item一起使用可以做輪播圖
基本使用,上代碼:
<swiper class="swiper-container">
<swiper-item>
<view class="item">A</view>
</swiper-item>
<swiper-item>
<view class="item">B</view>
</swiper-item>
<swiper-item>
<view class="item">C</view>
</swiper-item>
</swiper>
樣式
.swiper-container {
height: 150px;
}
.item{
height: 100%;
text-align: center;
line-height: 150px;
}
swiper-item:nth-child(1) .item{
background-color: pink;
}
swiper-item:nth-child(2) .item{
background-color: red;
}
swiper-item:nth-child(3) .item{
background-color: gold;
}
swiper當(dāng)中常用的屬性
屬性 | 類型 | 默認(rèn)值 | 說明 |
---|---|---|---|
indicator-dots | boolean | false | 是否顯示面板指示點(diǎn) |
indicator-color | color | rgba(0, 0, 0,.3) | 指示點(diǎn)顏色 |
indicator-active-color | color | false | 當(dāng)前選中的指示點(diǎn)顏色 |
autoplay | boolean | false | 是否自動切換 |
interval | number | 5000 | 自動切換時間間隔 |
circular | boolean | false | 是否采用銜接滑動 |
<!-- 屬性 indicator-dots -->
<swiper class="swiper-container" indicator-dots indicator-color="#fff" indicator-active-color="red" autoplay interval="2000" circular>
<swiper-item>
<view class="item">A</view>
</swiper-item>
<swiper-item>
<view class="item">B</view>
</swiper-item>
<swiper-item>
<view class="item">C</view>
</swiper-item>
</swiper>
文章來源:http://www.zghlxwxcb.cn/news/detail-852803.html
學(xué)如逆水行舟,不進(jìn)則退,感謝大家的閱讀!文章來源地址http://www.zghlxwxcb.cn/news/detail-852803.html
到了這里,關(guān)于初識微信小程序之swiper和swiper-item的基本使用的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!