You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
2.6 KiB

<template>
<view class="tabbar-container">
<block>
<view class="tabbar-item" v-for="(item, index) in tabbarList"
@click="changeItem(item)">
<view class="item-top">
<image :style="{width:item.width+'rpx',height:item.height+'rpx'}"
:src="currentItem == item.id ? item.selectedIconPath : item.iconPath"></image>
</view>
<view class="item-bottom" :class="[currentItem == item.id ? 'item-active' : '']">
<text>{{ item.text }}</text>
</view>
</view>
</block>
</view>
</template>
<script>
export default {
props: {
currentPage: {
type: Number,
default: 0
}
},
data() {
return {
currentItem: 0,
tabbarList: [{
id: 0,
centerItem: false,
width: 73,
height: 70,
"text": "首页",
"pagePath": "/pages/index/index",
"iconPath": require("@/static/index-home.png"),
"selectedIconPath": require("@/static/index-home-cur.png")
},
{
id: 1,
centerItem: false,
width: 59,
height: 69,
"text": "我的",
"pagePath": "/pages/me/me",
"iconPath": require("@/static/index-me.png"),
"selectedIconPath": require("@/static/index-me-cur.png")
}
]
};
},
mounted() {
this.currentItem = this.currentPage;
uni.hideTabBar();
},
methods: {
changeItem(item) {
let _this = this;
console.log(item.pagePath)
//_this.currentItem = item.id;
uni.switchTab({
url: item.pagePath
});
}
}
};
</script>
<style scoped>
view {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.tabbar-container {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 160rpx;
box-shadow: 0 0 10px #999;
display: flex;
align-items: center;
padding: 10rpx 0;
color: #6E6E6E;
z-index: 9999;
background: #fff;
background: #fff;
}
.tabbar-container .tabbar-item {
width: 50%;
/* height: 100rpx; */
display: flex;
flex-direction: column;
/* justify-content: center; */
align-items: center;
text-align: center;
}
.tabbar-container .item-active {
color: #e83f46;
}
.tabbar-container .center-item {
display: block;
position: relative;
}
.tabbar-container .tabbar-item .item-top {
/* width: 56rpx;
height: 44rpx; */
margin: 10rpx 0;
}
.tabbar-container .tabbar-item .item-top image {
vertical-align: middle;
}
.tabbar-container .tabbar-item .item-bottom {
font-size: 28rpx;
width: 100%;
}
.tabbar-container .center-item .item-bottom {
position: absolute;
bottom: 5rpx;
}
</style>