微信小程序修改swiper默認(rèn)指示器樣式的實(shí)例代碼
修改官方swiper樣式
從微信官方微信開發(fā)文檔中心復(fù)制swiper 代碼塊。
wxml定義
<view class="wrap"> <swiper class="swipers" autoplay="{{autoplay}}" current="{{currentSwiper}}" bindchange="swiperChange"> <block wx:for="{{imgUrls}}"> <swiper-item> <image src="{{item}}" class="slide-image" width="100%" height="150" ></image> </swiper-item> </block> </swiper> <!--重置小圓點(diǎn)的樣式 --> <view class="dots"> <block wx:for="{{imgUrls}}"> <view class="dot{{index == currentSwiper ? ' active' : ''}}"></view> </block> </view> </view>
wxss定義樣式
.wrap { height: auto; position: relative; width: 100%; } .swipers { height: 350rpx; width: 100%; } .slide-image { display: block; width: 100%; height: 100%; } /*用來包裹所有的小圓點(diǎn) */ .dots { width: 156rpx; height: 36rpx; display: flex; flex-direction: row; position: absolute; left: 320rpx; bottom: 20rpx; } /*未選中時(shí)的小圓點(diǎn)樣式 */ .dot { width: 26rpx; height: 26rpx; border-radius: 50%; margin-right: 26rpx; background-color: white; } /*選中以后的小圓點(diǎn)樣式 */ .active { width: 26rpx; height: 26rpx; background-color: coral; }
賦值
Page({ data: { imgUrls: [ 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg', 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg', 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg' ], currentSwiper: 0, autoplay: true }, swiperChange: function (e) { this.setData({ currentSwiper: e.detail.current }) } })
效果圖:
總結(jié)
以上所述是小編給大家介紹的微信小程序修改swiper默認(rèn)指示器樣式的實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- 微信小程序 swiper組件輪播圖詳解及實(shí)例
- 微信小程序 swiper制作tab切換實(shí)現(xiàn)附源碼
- 微信小程序 解決swiper不顯示圖片的方法
- 微信小程序?qū)崿F(xiàn)頂部選項(xiàng)卡(swiper)
- 微信小程序?qū)崿F(xiàn)tab和swiper切換結(jié)合效果
- 微信小程序 <swiper-item>標(biāo)簽傳入數(shù)據(jù)
- 微信小程序使用swiper組件實(shí)現(xiàn)類3D輪播圖
- 微信小程序swiper組件用法實(shí)例分析【附源碼下載】
- 微信小程序?qū)崿F(xiàn)swiper切換卡內(nèi)嵌滾動(dòng)條不顯示的方法示例
相關(guān)文章
div浮層,滾動(dòng)條移動(dòng),位置保持不變的4種方法匯總
這篇文章主要是對(duì)div浮層,滾動(dòng)條移動(dòng),位置保持不變的4種方法進(jìn)行了匯總介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2013-12-12javascript高仿熱血傳奇游戲?qū)崿F(xiàn)代碼
這篇文章主要介紹了javascript高仿熱血傳奇游戲的實(shí)現(xiàn)代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2018-02-02bootstrapValidator 重新啟用提交按鈕的方法
bootstrapValidator 使用中,由于字段檢查等原因,致使提交按鈕失效。如何重新啟用提交按鈕呢?下面小編給大家介紹下bootstrapValidator 重新啟用提交按鈕的方法,需要的朋友可以參考下2017-02-02微信小程序獲取用戶手機(jī)號(hào)碼的詳細(xì)步驟
最近改了一個(gè)公司項(xiàng)目,新增加了一個(gè)獲取用戶手機(jī)號(hào)功能,里面用到了關(guān)于獲取用戶信息和用戶手機(jī)號(hào)的功能,下面這篇文章主要給大家介紹了關(guān)于微信小程序獲取用戶手機(jī)號(hào)碼的相關(guān)資料,需要的朋友可以參考下2022-07-07推薦js實(shí)現(xiàn)商品分類到搜索欄友好提示(人機(jī)交互)
推薦js實(shí)現(xiàn)商品分類到搜索欄友好提示(人機(jī)交互)...2007-05-05用javascript實(shí)現(xiàn)div可編輯的常見方法
用javascript實(shí)現(xiàn)div可編輯的常見方法...2007-10-10