W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
滑塊視圖容器,其中只可放置 <swiper-item/>
組件,否則可能導(dǎo)致異常。
屬性名 | 類型 | 默認(rèn)值 | 說明 | 最低版本 |
---|---|---|---|---|
indicator-dots | Boolean | false | 是否顯示面板指示點(diǎn) | 1.0.0 |
indicator-color | String | rgba(0, 0, 0, .3) | 指示點(diǎn)顏色 | 1.0.0 |
indicator-active-color | String | rgba(0, 0, 0, 0) | 當(dāng)前選中的指示點(diǎn)顏色 | 1.0.0 |
autoplay | Boolean | false | 是否自動(dòng)切換 | 1.0.0 |
current | Number | 0 | 當(dāng)前選中滑塊的index | 1.0.0 |
current-item-id | String | "" | 當(dāng)前選中滑塊的組件id,不能與current屬性同時(shí)指定 | 1.0.0 |
interval | Number | 5000 | 自動(dòng)切換時(shí)間間隔 | 1.0.0 |
display-multiple-items | Number | 1 | 同時(shí)顯示的滑塊數(shù)量 | 1.0.0 |
duration | Number | 500 | 滑動(dòng)動(dòng)畫時(shí)長(zhǎng) | 1.0.0 |
circular | Boolean | false | 是否循環(huán)播放(首尾銜接) | 1.0.0 |
vertical | Boolean | false | 滑塊放置方向是否為豎直 | 1.0.0 |
bindchange | EventHandler | current 改變時(shí)會(huì)觸發(fā) change 事件,event.detail = {current, source} | 1.0.0 | |
bindtransition | EventHandler | swiper-item產(chǎn)生位移時(shí)觸發(fā) transition 事件,event.detail = {dx, dy} | 1.20.0 |
change 事件的source字段表示導(dǎo)致改變的原因,可以有如下值:
滑塊視圖內(nèi)容。僅可放置在 <swiper/> 組件中,寬高自動(dòng)設(shè)置為100%。
屬性名 | 類型 | 默認(rèn)值 | 說明 | 最低版本 |
---|---|---|---|---|
item-id | String | "" | 組件id |
<view class="page-section">
<swiper indicator-dots="{{indicatorDots}}"
autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
<block tt:for="{{background}}">
<swiper-item>
<view class="swiper-item {{item}}"></view>
</swiper-item>
</block>
</swiper>
</view>
<view class="page-section">
<view class="ttui-cells">
<view class="ttui-cell">
<view class="ttui-cell__bd">指示點(diǎn)</view>
<view class="ttui-cell__ft">
<switch checked="{{indicatorDots}}" bindchange="changeIndicatorDots" />
</view>
</view>
<view class="ttui-cell">
<view class="ttui-cell__bd">自動(dòng)播放</view>
<view class="ttui-cell__ft">
<switch checked="{{autoplay}}" bindchange="changeAutoplay" />
</view>
</view>
</view>
</view>
Page({
data: {
background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
indicatorDots: true,
vertical: false,
autoplay: false,
interval: 2000,
duration: 500
},
changeIndicatorDots: function (e) {
this.setData({
indicatorDots: !this.data.indicatorDots
})
},
changeAutoplay: function (e) {
this.setData({
autoplay: !this.data.autoplay
})
},
intervalChange: function (e) {
this.setData({
interval: e.detail.value
})
},
durationChange: function (e) {
this.setData({
duration: e.detail.value
})
}
})
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: