本文實(shí)例為大家分享了小程序?qū)崿F(xiàn)選項(xiàng)卡效果的具體代碼,供大家參考,具體內(nèi)容如下
創(chuàng)新互聯(lián)建站-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比巴宜網(wǎng)站開(kāi)發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式巴宜網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋巴宜地區(qū)。費(fèi)用合理售后完善,十余年實(shí)體公司更值得信賴。
效果圖:
github源碼下載
{{item.title}} {{item.title}}
CSS:
/**index.wxss**/ /**index.wxss**/ .swiper-tab { line-height: 80rpx; border: 1px solid #ccc; display: flex; justify-content: space-around; align-items: center; } .swiper-tab-list { font-size: 30rpx; color: #777; text-align: center; } .active { color: #da7c0c; border-bottom: 5rpx solid #da7c0c; } .swiper-box { display: block; height: 100%; width: 100%; overflow: hidden; } .swiper-box view { text-align: center; } image { width: 100%; }
js:
Page({ /** * 頁(yè)面的初始數(shù)據(jù) */ data: { currentTab:0, tabCont: [{ "title": "tab1", "pic": "../../img/1.jpg", "index": "0" }, { "title": "tab2", "pic": "../../img/2.jpg", "index": "1" }, { "title": "tab3", "pic": "../../img/3.jpg", "index": "2" }, { "title": "tab4", "pic": "../../img/2.jpg", "index": "3" }, { "title": "tab5", "pic": "../../img/2.jpg", "index": "4" }, { "title": "tab6", "pic": "../../img/2.jpg", "index": "5" }, { "title": "tab7", "pic": "../../img/2.jpg", "index": "6" }, { "title": "tab8", "pic": "../../img/2.jpg", "index": "7" }, { "title": "tab9", "pic": "../../img/2.jpg", "index": "8" }], }, /** * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載 */ onLoad: function (options) { }, /** * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面初次渲染完成 */ onReady: function () { }, /** * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面顯示 */ onShow: function () { }, /** * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面隱藏 */ onHide: function () { }, /** * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面卸載 */ onUnload: function () { }, /** * 頁(yè)面相關(guān)事件處理函數(shù)--監(jiān)聽(tīng)用戶下拉動(dòng)作 */ onPullDownRefresh: function () { }, /** * 頁(yè)面上拉觸底事件的處理函數(shù) */ onReachBottom: function () { }, /** * 用戶點(diǎn)擊右上角分享 */ onShareAppMessage: function () { }, // swiper滑動(dòng)時(shí)觸發(fā)bindchange事件,獲取事件對(duì)象e獲取當(dāng)前所在滑塊的 index,并將其更新至data的currentTab中,視圖渲染通過(guò)判斷currentTab的讓對(duì)應(yīng)的tab hover。 GetCurrentTab:function(e){ console.log(e.detail.current); var that = this; this.setData({ currentTab:e.detail.current }); // console.log("11111"+this.data.currentTab); }, swithNav:function(e){ var that = this; that.setData({ currentTab:e.target.dataset.current }); } })
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。