開發小程式,怎麼制作輪播多圖的效果?
1.用第三方平台制作小程式,不需要寫代碼,想要制作出輪播圖的效果,隻需要進入【Design Lab】,拖拽添加【輪播多圖】元件,右鍵編輯即可。
2.自己寫代碼開發小程式,使用的是容器元件中的--swiper,
在.wxml裡面添加三個輪播:
<swiper>
<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>
在.wxss檔案中加樣式,包括輪播區域固定高度,每張輪播圖的大小和高度,對齊效果,以及背景顔色。
.swiper-container{
height:150px;
}
.item{
height:100%;
line-height:150px;
text-align:center;
}
swiper-item:nth-child(1) .item{
background-color: rgb(251, 206, 255);
}
swiper-item:nth-child(2) .item{
background-color: rgb(247, 255, 174);
}
swiper-item:nth-child(3) .item{
background-color: rgb(174, 202, 255);
}
swiper元件的常用屬性包括indicator(是否顯示面闆訓示點),indicator-color(訓示點顔色),indicator-active-color(目前選中的訓示點顔色),autoplay(是否自動切換),interval(自動切換時間間隔),circular(是否采用銜接滑動)
看到這裡,相信很多人開始覺得頭暈眼花了,沒有關系,不是還有第一種方法嗎,在第三方平台設定圖檔輪播,隻需要右鍵編輯。
無論是寫代碼,還是用第三方平台,都能開發小程式,隻是難度不同,耗費的時間不同,出來的效果可以一模一樣。
#輕棧##小程式##小程式開發包含哪些内容#