微信小程序?qū)崿F(xiàn)選項(xiàng)卡效果
本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)選項(xiàng)卡效果展示的具體代碼,供大家參考,具體內(nèi)容如下
demo.wxss
.swiper-tab{ width: 100%; border-bottom: 2rpx solid #777777; text-align: center; line-height: 80rpx;} .swiper-tab-list{ font-size: 30rpx; display: inline-block; width: 33.33%; color: #777777; } .on{ color: #da7c0c; border-bottom: 5rpx solid #da7c0c;} .swiper-box{ display: block; height: 100%; width: 100%; overflow: hidden; } .swiper-box view{ text-align: center; }
demo.wxml
<view class="swiper-tab"> <view class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">哈哈</view> <view class="swiper-tab-list {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">呵呵</view> <view class="swiper-tab-list {{currentTab==2 ? 'on' : ''}}" data-current="2" bindtap="swichNav">嘿嘿</view> </view> <swiper current="{{currentTab}}" class="swiper-box" duration="300" style="height:{{winHeight - 31}}px" bindchange="bindChange"> <!-- 我是哈哈 --> <swiper-item> <view>我是哈哈</view> </swiper-item> <!-- 我是呵呵 --> <swiper-item> <view>我是呵呵</view> </swiper-item> <!-- 我是嘿嘿 --> <swiper-item> <view>我是嘿嘿</view> </swiper-item> </swiper>
demo.js
Page( { data: { /** * 頁面配置 */ winWidth: 0, winHeight: 0, // tab切換 currentTab: 0, }, onLoad: function() { var that = this; /** * 獲取系統(tǒng)信息 */ wx.getSystemInfo( { success: function( res ) { that.setData( { winWidth: res.windowWidth, winHeight: res.windowHeight }); } }); }, /** * 滑動(dòng)切換tab */ bindChange: function( e ) { var that = this; that.setData( { currentTab: e.detail.current }); }, /** * 點(diǎn)擊tab切換 */ swichNav: function( e ) { var that = this; if( this.data.currentTab === e.target.dataset.current ) { return false; } else { that.setData( { currentTab: e.target.dataset.current }) } } })
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 微信小程序自定義組件實(shí)現(xiàn)tabs選項(xiàng)卡功能
- 微信小程序?qū)崿F(xiàn)導(dǎo)航欄選項(xiàng)卡效果
- 微信小程序?qū)崿F(xiàn)選項(xiàng)卡功能
- 微信小程序之選項(xiàng)卡的實(shí)現(xiàn)方法
- 微信小程序?qū)崿F(xiàn)頂部普通選項(xiàng)卡效果(非swiper)
- 微信小程序?qū)崿F(xiàn)頂部選項(xiàng)卡(swiper)
- 微信小程序 選項(xiàng)卡的簡(jiǎn)單實(shí)例
- 微信小程序?qū)崙?zhàn)之頂部導(dǎo)航欄(選項(xiàng)卡)(1)
- 微信小程序開發(fā)之選項(xiàng)卡(窗口底部TabBar)頁面切換
- 微信小程序 tabs選項(xiàng)卡效果的實(shí)現(xiàn)
- 微信小程序開發(fā)之實(shí)現(xiàn)選項(xiàng)卡(窗口頂部TabBar)頁面切換
- 微信小程序 實(shí)現(xiàn)tabs選項(xiàng)卡效果實(shí)例代碼
- 小程序?qū)崿F(xiàn)頁面頂部選項(xiàng)卡效果
相關(guān)文章
Ionic 2 實(shí)現(xiàn)列表滑動(dòng)刪除按鈕的方法
這篇教程將展示如何使用Ionic2添加一個(gè)簡(jiǎn)單的刪除按鈕到列表,當(dāng)用戶滑動(dòng)列表項(xiàng)到左邊的時(shí)候。這是一個(gè)處理刪除列表數(shù)據(jù)時(shí)候常用的模式,具體內(nèi)容大家通過本文學(xué)習(xí)吧2017-01-01原生JS實(shí)現(xiàn)動(dòng)態(tài)添加新元素、刪除元素方法
這篇文章主要介紹了原生js實(shí)現(xiàn)動(dòng)態(tài)添加新元素、刪除元素方法 ,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-05-05JS實(shí)現(xiàn)仿QQ效果的三級(jí)豎向菜單
這篇文章主要介紹了JS實(shí)現(xiàn)仿QQ效果的三級(jí)豎向菜單,以實(shí)例形式分析了JavaScript遍歷頁面元素及動(dòng)態(tài)改變頁面css樣式的技巧,需要的朋友可以參考下2015-09-09JS實(shí)現(xiàn)為動(dòng)態(tài)創(chuàng)建的元素添加事件操作示例
這篇文章主要介紹了JS實(shí)現(xiàn)為動(dòng)態(tài)創(chuàng)建的元素添加事件操作,涉及javascript頁面元素動(dòng)態(tài)添加及事件響應(yīng)相關(guān)操作技巧,需要的朋友可以參考下2018-03-03Three.js實(shí)現(xiàn)簡(jiǎn)單3D房間布局
這篇文章主要為大家詳細(xì)介紹了Three.js實(shí)現(xiàn)簡(jiǎn)單3D房間布局的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-12-12