小程序?qū)崿F(xiàn)tab更換頁面效果
本文實(shí)例為大家分享了小程序?qū)崿F(xiàn)tab更換頁面效果的具體代碼,供大家參考,具體內(nèi)容如下

.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="" data-item="{{ip}}">
? ?{{ip.title}}
? </view>
?</block>
?<view class="ip_tab_comtainer_padd"></view>
</scroll-view>
<view class='content'>
<block>
<view class="content1" wx:if="{{content=='日統(tǒng)計(jì)'}}">{{content}}</view>
<view class="content2" wx:if="{{content=='月統(tǒng)計(jì)'}}">{{content}}</view>
<view class="content3" wx:if="{{content=='年統(tǒng)計(jì)'}}">{{content}}</view>
</block>
</view>.wxss
page{
?
? width: 100%;
? height: 100%;
?
}
?
.ip_tab_comtainer {
?
? width: 100%;
? background-color: #F5F5F5;
? padding: 20rpx 0 0;
? white-space: nowrap;
?
}
?
.ip_tab_comtainer_padd {
?
? display: inline-block;
? ?width: 5%;?
?
}
?
.ip_tab_item_s {
?
? width: 30%;
? display: inline-block;
? line-height: 40rpx;
? text-align: center;
? color: #91daf9;
? font-size: 28rpx;
? overflow: hidden;
? background-color: #ffffff;
? border: 1px solid #91daf9;
?
}
?
.ip_tab_item_n {
?
? width: 30%;
? display: inline-block;
? text-align: center;
? line-height: 40rpx;
? color: #353535;
? background-color: #ffffff;
? 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%;
? height: 100%;
? display: flex;
? background-color: #CCCCCC;
??
?}
?
?
.content1{
?
? width: 100%;
? height: 100%;
? display: flex;
? background-color: #6b10e0;
?
?}
?
?.content2{
?
? width: 100%;
? height: 100%;
? display: flex;
? background-color: #d41515;
?
?}
?
?.content3{
?
? width: 100%;
? height: 100%;
? display: flex;
? background-color: #1ac729;
?
?}.js
?/**
? ?* 頁面的初始數(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: "日統(tǒng)計(jì)"
??
? },
? /**
? * 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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JS首屏加載時(shí)間優(yōu)化的解決方法總結(jié)
首屏加載時(shí)間是一個(gè)衡量網(wǎng)頁性能和用戶體驗(yàn)的關(guān)鍵指標(biāo),這個(gè)問題無論是在面試中還是在項(xiàng)目開發(fā)中都占有極其高的權(quán)重,本文為大家整理了幾種JS中優(yōu)化首屏加載時(shí)間的方法,希望對大家有所幫助2024-02-02
手機(jī)注冊發(fā)送驗(yàn)證碼倒計(jì)時(shí)的簡單實(shí)例
下面小編就為大家分享一篇手機(jī)注冊發(fā)送驗(yàn)證碼倒計(jì)時(shí)的簡單實(shí)例。具有很好的參考價(jià)值,一起跟隨小編過來看看吧,希望對大家有所幫助2017-11-11
JavaScript操作XML 使用百度RSS作為新聞源示例
JavaScript操作XML 使用百度RSS作為新聞源示例,需要的朋友可以參考下2012-02-02
js實(shí)現(xiàn)前面自動(dòng)補(bǔ)全位數(shù)的方法
今天小編就為大家分享一篇js實(shí)現(xiàn)前面自動(dòng)補(bǔ)全位數(shù)的方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-10-10
微信小程序使用scroll-view標(biāo)簽實(shí)現(xiàn)自動(dòng)滑動(dòng)到底部功能的實(shí)例代碼
本文通過實(shí)例代碼給大家介紹了微信小程序使用scroll-view標(biāo)簽實(shí)現(xiàn)自動(dòng)滑動(dòng)到底部功能,代碼簡單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2018-11-11

