這篇文章主要介紹了微信小程序怎樣實現(xiàn)一個簡單的Tab可滑動的切換方式,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
高港ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!
最近一直在做小程序項目,對于不同需求來說真是煩不勝煩,之前做的訂單頁來說只需要可點擊切換就可以,但是在后期的迭代中提到要求可滑動切換,下面我自己整理了一套比較簡單暴力的滑動切換方式,與大家共享一下,下面有效果圖。(菜鳥上路,不喜勿噴):
.wxml
<!--pages/mine/order/order.wxml-->
<view class='order'>
<view class="swiper-tab">
<view class="swiper-tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="clickTab">代付款</view>
<view class="swiper-tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="clickTab">代發(fā)貨</view>
<view class="swiper-tab-item {{currentTab==2?'active':''}}" data-current="2" bindtap="clickTab">待收貨</view>
<view class="swiper-tab-item {{currentTab==3?'active':''}}" data-current="3" bindtap="clickTab">待評價</view>
<view class="swiper-tab-item {{currentTab==4?'active':''}}" data-current="4" bindtap="clickTab">退款/售后</view>
</view>
<swiper current="{{currentTab}}" duration="300" bindchange="swiperTab">
<swiper-item>
<view>代付款</view>
</swiper-item>
<swiper-item>
<view>代發(fā)貨</view>
</swiper-item>
<swiper-item>
<view>待收貨</view>
</swiper-item>
<swiper-item>
<view>待評價</view>
</swiper-item>
<swiper-item>
<view>退款/售后</view>
</swiper-item>
</swiper>
</view>.wxss
/* pages/mine/order/order.wxss */
.swiper-tab {
width: 100%;
border-bottom: 2rpx solid #ccc;
text-align: center;
height: 88rpx;
line-height: 88rpx;
display: flex;
flex-flow: row;
justify-content: space-between;
}
.swiper-tab-item {
width: 30%;
color: #434343;
font-size: 28rpx;
}
.active {
color: #f65959;
border-bottom: 4rpx solid #f65959;
}
swiper {
text-align: center;
background-color: #fff
}.js
// pages/mine/order/order.js
Page({
/**
* 頁面的初始數(shù)據(jù)
*/
data: {
currentTab: 0
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面加載
*/
onLoad: function (options) {
},
//滑動切換
swiperTab: function (e) {
this.setData({
currentTab: e.detail.current
});
},
//點擊切換
clickTab: function (e) {
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
this.setData({
currentTab: e.target.dataset.current
})
}
}
})效果圖:
在wxml部分其實可以用個wx:for 來做。
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“微信小程序怎樣實現(xiàn)一個簡單的Tab可滑動的切換方式”這篇文章對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識等著你來學(xué)習(xí)!
文章名稱:微信小程序怎樣實現(xiàn)一個簡單的Tab可滑動的切換方式
URL鏈接:http://www.yijiale78.com/article22/ghdijc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、響應(yīng)式網(wǎng)站、微信小程序、商城網(wǎng)站、品牌網(wǎng)站建設(shè)、手機網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)