微信小程序 選項(xiàng)卡的簡(jiǎn)單實(shí)例
微信小程序 選項(xiàng)卡的簡(jiǎn)單實(shí)例
看下效果
代碼:
home.wxml
<!--pages/home/home.wxml--> <view class="swiper-tab"> <view class="swiper-tab-item {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">熱門</view> <view class="swiper-tab-item {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">關(guān)注</view> <view class="swiper-tab-item {{currentTab==2 ? 'on' : ''}}" data-current="2" bindtap="swichNav">好友</view> </view> <swiper current="{{currentTab}}" class="swiper-box" duration="300" style="height:{{winHeight - 80}}px" bindchange="bindChange"> <swiper-item> <view>熱門</view> </swiper-item> <swiper-item> <view>關(guān)注</view> </swiper-item> <swiper-item> <view>好友</view> </swiper-item> </swiper>
home.wxss
/* pages/home/home.wxss */ .swiper-tab{ width: 100%; border-bottom: 2rpx solid #eeeeee; text-align: center; line-height: 80rpx;} .swiper-tab-item{ font-size: 30rpx; display: inline-block; width: 33.33%; color: #666666; } .on{ color: #f10b2e; border-bottom: 5rpx solid #f10b2e;} .swiper-box{ display: block; height: 100%; width: 100%; overflow: hidden; } .swiper-box view{ text-align: center; }
home.js
// pages/home/home.js var app = getApp() Page({ data: { winWidth: 0, winHeight: 0, // tab切換 currentTab: 0, }, onLoad: function () { var that = this; wx.getSystemInfo({ success: function (res) { that.setData({ winWidth: res.windowWidth, winHeight: res.windowHeight }); } }); }, bindChange: function (e) { var that = this; that.setData({ currentTab: e.detail.current }); }, swichNav: function (e) { var that = this; if (this.data.currentTab === e.target.dataset.current) { return false; } else { that.setData({ currentTab: e.target.dataset.current }) } } })
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
- 微信小程序開發(fā)之實(shí)現(xiàn)選項(xiàng)卡(窗口頂部TabBar)頁(yè)面切換
- 微信小程序?qū)崿F(xiàn)選項(xiàng)卡功能
- 微信小程序的tab選項(xiàng)卡的實(shí)現(xiàn)效果
- 微信小程序開發(fā)之選項(xiàng)卡(窗口底部TabBar)頁(yè)面切換
- 微信小程序 tabs選項(xiàng)卡效果的實(shí)現(xiàn)
- 微信小程序?qū)崙?zhàn)之頂部導(dǎo)航欄(選項(xiàng)卡)(1)
- 微信小程序?qū)崿F(xiàn)頂部選項(xiàng)卡(swiper)
- 微信小程序自定義組件實(shí)現(xiàn)tabs選項(xiàng)卡功能
- 微信小程序?qū)崿F(xiàn)選項(xiàng)卡的簡(jiǎn)單實(shí)例
- 微信小程序?qū)崿F(xiàn)選項(xiàng)卡的方法
相關(guān)文章
JavaScript loader原理簡(jiǎn)單總結(jié)示例解析
這篇文章主要為大家介紹了JavaScript loader原理簡(jiǎn)單總結(jié)示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08JavaScript?設(shè)計(jì)模式之洋蔥模型原理及實(shí)踐應(yīng)用
這篇文章主要介紹了JavaScript?設(shè)計(jì)模式之洋蔥模型原理及實(shí)踐應(yīng)用,主要針對(duì)項(xiàng)目中遇到的問題,引申到koa-compose原理解析。通過學(xué)習(xí)洋蔥模式來解決我們實(shí)際項(xiàng)目中的問題2022-09-09Electron學(xué)習(xí)應(yīng)用程序打包實(shí)例詳解
這篇文章主要介紹了Electron學(xué)習(xí)應(yīng)用程序打包實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09javascript進(jìn)階篇深拷貝實(shí)現(xiàn)的四種方式
這篇文章主要為大家介紹了javascript進(jìn)階篇深拷貝實(shí)現(xiàn)的四種方式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07詳解微信小程序開發(fā)之——wx.showToast(OBJECT)的使用
本篇文章主要介紹了微信小程序開發(fā)之——wx.showToast(OBJECT)的使用,具有一定的參考價(jià)值,有興趣的可以了解一下。2017-01-01JavaScript 中有了Object 為什么還需要 Map 呢
Map 是用于存儲(chǔ)鍵值的,而 JavaScript 中對(duì)象也是由鍵值對(duì)組成的,那么 Map 存在的意義是什么呢?下面文章小編就來向大家詳細(xì)介紹吧,需要的朋友可以參考下2021-09-09微信小程序 選項(xiàng)卡的簡(jiǎn)單實(shí)例
這篇文章主要介紹了微信小程序 選項(xiàng)卡的簡(jiǎn)單實(shí)例的相關(guān)資料,需要的朋友可以參考下2017-05-05微信小程序 教程之wxapp視圖容器 scroll-view
這篇文章主要介紹了微信小程序 教程之wxapp視圖容器 scroll-view的相關(guān)資料,需要的朋友可以參考下2016-10-10微信小程序 數(shù)組(增,刪,改,查)等操作實(shí)例詳解
這篇文章主要介紹了微信小程序 數(shù)組(增,刪,改,查)等操作實(shí)例詳解的相關(guān)資料,這里對(duì)小程序的數(shù)組進(jìn)行操作,簡(jiǎn)單實(shí)例,需要的朋友可以參考下2017-01-01