微信小程序swiper左右擴展各顯示一半代碼實例
更新時間:2019年12月05日 11:26:15 作者:故事外的人呀
這篇文章主要介紹了微信小程序swiper左右擴展各顯示一半代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
這篇文章主要介紹了微信小程序swiper左右擴展各顯示一半代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
實現(xiàn)如下的功能:
動圖展示效果
代碼如下:
index.wxml
<swiper class='swiper' next-margin='120rpx' bindchange='swiper'> <block wx:for="{{devices}}" wx:key="" wx:for-item="device"> <swiper-item item-id="{{device.type}}"> <view class="device {{swiperIndex == index ?'active':''}}" data-currentTab="{{index}}"> <view class='device-img'> <image src='{{device.deviceImg}}'></image> </view> </view> </swiper-item> </block> </swiper>
index.js
Page({ data: { swiperIndex: 0, // 設(shè)置頁面 devices: [ { deviceImg: "../../img/1.jpg" }, { deviceImg: "../../img/2.jpg" }, { deviceImg: "../../img/3.jpg" } ], }, swiper: function (e) { let that = this; let index = e.detail.current; that.setData({ swiperIndex: index }); } })
index.wss
/* 輪播圖 */ .devices{ width: 638rpx; } .swiper{ width: 580rpx; height: 600rpx; margin-left:48rpx; white-space:nowrap; /* border: solid red 1px; */ } .device{ width: 410rpx; height: 94%; display:inline-block; margin-left: 20rpx; background: rosybrown; transform: scale(0.9); transition:all .2s ease 0s; } .active{ transform: none; transition: all 0.2s ease-in 0s; } .device-img{ width: 100%; height: 520rpx; margin-top: 40rpx; display: flex; justify-content: center; align-items: center; } .device-img image{ width:350rpx; height:190rpx; }
index.json
{ "usingComponents": {} }
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Ajax,UTF-8還是GB2312 eval 還是execScript
討厭的東西。 關(guān)于Ajax獲取HTML內(nèi)容編碼,與JavaScript載入腳本的動態(tài)執(zhí)行問題。2008-11-11使用JS將字符串保存成文件到本地(.txt、.json、.md)
工作中有時需要通過JavaScript保存文件到本地,下面這篇文章主要給大家介紹了關(guān)于使用JS將字符串保存成文件到本地的相關(guān)資料,分別包括生成.txt、.json、.md等文件,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2023-06-06