這篇文章將為大家詳細(xì)講解有關(guān)微信小程序用視圖容器(swiper)組件創(chuàng)建輪播圖的方法,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
10年積累的成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站制作后付款的網(wǎng)站建設(shè)流程,更有蒲縣免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
一、視圖容器(Swiper)
1、swiper:滑塊視圖容器
微信官方文檔


二、swiper應(yīng)用
1、頁(yè)面邏輯(index.js)
Page({
data: {
imgUrls: [
{
link: '/pages/index/index',
url: '/images/001.jpg'
}, {
link: '/pages/list/list',
url: '/images/002.jpg'
}, {
link: '/pages/list/list',
url: '/images/003.jpg'
}
],
indicatorDots: true, //小點(diǎn)
indicatorColor: "white",//指示點(diǎn)顏色
activeColor: "coral",//當(dāng)前選中的指示點(diǎn)顏色
autoplay: false, //是否自動(dòng)輪播
interval: 3000, //間隔時(shí)間
duration: 3000, //滑動(dòng)時(shí)間
}其中 imgUrls 是我們輪播圖中將要用到的 圖片地址和 跳轉(zhuǎn)鏈接
indicatgorDots 是否出現(xiàn)焦點(diǎn)
autoplay 是否自動(dòng)播放
interval 自動(dòng)播放間隔時(shí)間
duration 滑動(dòng)動(dòng)畫時(shí)間
2、頁(yè)面結(jié)構(gòu)(index.wxml)
<!--輪播圖-->
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" indicator-color="{{indicatorColor}}"
indicator-active-color="{{activeColor}}">
<block wx:for="{{imgUrls}}">
<swiper-item>
<navigator url="{{item.link}}" hover-class="navigator-hover">
<image src="{{item.url}}" class="slide-image" width="355" height="200" />
</navigator>
</swiper-item>
</block>
</swiper>注意:swiper 千萬不要在外面 加上任何標(biāo)簽 例如 <view> 之類的 ,如果加了可能會(huì)導(dǎo)致輪播圖出不來
3、頁(yè)面樣式(index.wxss)
/*輪播圖*/
.slide-image {
width: 100%;
}三、小程序效果圖
趕快動(dòng)手實(shí)踐就可以看到如圖所示效果圖:

關(guān)于微信小程序用視圖容器(swiper)組件創(chuàng)建輪播圖的方法就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
當(dāng)前題目:微信小程序用視圖容器(swiper)組件創(chuàng)建輪播圖的方法
文章地址:http://www.chinadenli.net/article38/piiosp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、App設(shè)計(jì)、企業(yè)網(wǎng)站制作、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站收錄、微信公眾號(hào)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)