微信小程序輪播圖swiper代碼詳解
微信小程序自定義swiper
滑塊視圖容器。其中只可放置swiper-item組件,否則會(huì)導(dǎo)致未定義的行為。



先在index.wxml中寫
style=“background:{{item}}” 報(bào)錯(cuò)不要管,不影響頁(yè)面布局
<view class="container">
<swiper class="swiper1"
indicator-dots="{{indicatorDots}}" 是否顯示面板指示點(diǎn)
autoplay="{{autoplay}}" 是否自動(dòng)切換
interval="{{interval}}" 自動(dòng)切換時(shí)間間隔
duration="{{duration}}" 滑動(dòng)動(dòng)畫時(shí)長(zhǎng)
circular="{{circular}}" 是否采用銜接滑動(dòng)
indicator-active-color="#ff0099" 選中指示點(diǎn)顏色
>
<block wx:for="{{background}}" wx:key="index"> 循環(huán)遍歷數(shù)據(jù)
<swiper-item>
<view class="swiper-item" style="background:{{item}}"></view>
</swiper-item>
</block>
</swiper>
</view>
再在index.js中寫
Page({
data: {
background: ["red", "pink","yellowgreen"],
indicatorDots: true,
vertical: false,
autoplay: true,
interval: 2000,
duration: 500,
circular:true
}
})
最后在index.wxss中寫
.swiper1{
width: 100%;
height: 200px;
}
.swiper-item{
width: 100%;
height: 100%;
}
記?。?/strong>
圖片跟背景顏色思路一樣
到此這篇關(guān)于微信小程序輪播圖swiper代碼的文章就介紹到這了,更多相關(guān)微信小程序輪播圖swiper代碼內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
js實(shí)現(xiàn)彩色條紋滾動(dòng)條效果
本文主要介紹了js實(shí)現(xiàn)彩色條紋滾動(dòng)條效果的實(shí)例。具有很好的參考價(jià)值。下面跟著小編一起來看下吧2017-03-03
js實(shí)現(xiàn)九宮格的隨機(jī)顏色跳轉(zhuǎn)
本篇文章主要介紹了js實(shí)現(xiàn)九宮格的隨機(jī)顏色跳轉(zhuǎn)的示例代碼,具有很好的參考價(jià)值,下面跟著小編一起來看下吧2017-02-02

