怎么在微信小程序中實(shí)現(xiàn)tab頁(yè)面切換功能?很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。
站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到達(dá)坂城網(wǎng)站設(shè)計(jì)與達(dá)坂城網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都做網(wǎng)站、網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、空間域名、網(wǎng)頁(yè)空間、企業(yè)郵箱。業(yè)務(wù)覆蓋達(dá)坂城地區(qū)。
wxml
<scroll-view scroll-x="true" class="ip_tab_comtainer"> <view class="ip_tab_comtainer_padd"></view> <block wx:for="{{ips}}" wx:for-item="ip" wx:key="{{ip.id}}"> <view class="{{ip.isSelect?'ip_tab_item_s':'ip_tab_item_n'}}" bindtap="onIpItemClick" wx:key="{{ip.id}}" data-item="{{ip}}"> {{ip.title}} </view> </block> <view class="ip_tab_comtainer_padd"></view> </scroll-view> <view class='content'> {{content}} </view>
wxss
.ip_tab_comtainer { width: 100%; background-color: #F5F5F5; padding: 20rpx 0 0; white-space: nowrap; } .ip_tab_comtainer_padd { display: inline-block; width: 24rpx; } .ip_tab_item_s { display: inline-block; line-height: 40rpx; padding: 12rpx 32rpx; color: #91daf9; margin-right: 8rpx; margin-left: 8rpx; font-size: 28rpx; overflow: hidden; background-color: #ffffff; border: 1px solid #91daf9; } .ip_tab_item_n { display: inline-block; padding: 12rpx 32rpx; line-height: 40rpx; color: #353535; margin-right: 8rpx; background-color: #ffffff; margin-left: 8rpx; font-size: 28rpx; text-align: center; overflow: hidden; text-overflow: ellipsis; border-radius: 4rpx; border: 1px solid #CCCCCC; } /** 去除橫向滾動(dòng)條 */ ::-webkit-scrollbar { width: 0; height: 0; color: transparent; } .content{ width: 100%; }
js
// pages/horizontal-scroll_tab/horizontal-scroll_tab.js Page({ /** * 頁(yè)面的初始數(shù)據(jù) */ data: { ips: [ { id: "1", title: "日統(tǒng)計(jì)", isSelect:true }, { id: "2", title: "月統(tǒng)計(jì)", isSelect: false}, { id: "3", title: "年統(tǒng)計(jì)", isSelect: false}, ], content:"全部" }, /** * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載 */ onLoad: function (options) { }, /** * item點(diǎn)擊事件 */ onIpItemClick: function (event) { console.log(event); var id = event.currentTarget.dataset.item.id; var curIndex = 0; for (var i = 0; i < this.data.ips.length; i++) { if (id == this.data.ips[i].id) { this.data.ips[i].isSelect = true; curIndex = i; } else { this.data.ips[i].isSelect = false; } } this.setData({ content: this.data.ips[curIndex].title, ips: this.data.ips, }); }, })
看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。
當(dāng)前標(biāo)題:怎么在微信小程序中實(shí)現(xiàn)tab頁(yè)面切換功能
分享路徑:http://www.ekvhdxd.cn/article14/iijcge.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、用戶體驗(yàn)、網(wǎng)站建設(shè)、品牌網(wǎng)站設(shè)計(jì)、Google、定制開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)