uni-Identify-quality/components/fl-tabbar/fl-tabbar.vue

93 lines
2.1 KiB
Vue
Raw Normal View History

2023-09-19 01:40:04 +00:00
<template>
<view>
<view class="status_bar">
<!-- 这里是状态栏 -->
</view>
<u-tabbar :value="current"
@change="changeTab"
:fixed="true"
:placeholder="false"
:safeAreaInsetBottom="true"
:border="false"
activeColor="#FFC748"
inactiveColor="#1D1D1D">
<u-tabbar-item v-for="(item,index) in tabBarList"
:key="index"
:text="item.text">
<image class="u-page__item__slot-icon"
slot="inactive-icon"
:src="item.iconPath"></image>
<image class="u-page__item__slot-icon"
slot="active-icon"
:src="item.selectedIconPath"></image>
</u-tabbar-item>
</u-tabbar>
</view>
</template>
<script>
export default {
props: {
currentPage: String
},
data () {
return {
current: 0,
tabBarList: [{
pagePath: "pages/home/index",
iconPath: "../../static/tabbar/home.png",
selectedIconPath: "../../static/tabbar/home-active.png",
text: '首页',
customIcon: false,
},
{
pagePath: "pages/mine/index",
iconPath: "../../static/tabbar/my.png",
selectedIconPath: "../../static/tabbar/my-active.png",
text: '我的',
customIcon: false,
}
]
};
},
methods: {
changeTab (e) {
let page = '/' + this.tabBarList[e].pagePath
console.log(page);
uni.switchTab({
url: page,
success: () => {
},
fail: (e) => {
console.log(e);
}
})
}
},
created () {
//隐藏原生tabbar
uni.hideTabBar();
// 当前选中的菜单
this.tabBarList.forEach((i, index) => {
if (i.pagePath == this.currentPage) {
this.current = index
}
})
},
}
</script>
<style lang="scss" scoped>
.u-page__item__slot-icon {
width: 76rpx;
height: 76rpx;
}
.u-tabbar /deep/ .u-tabbar--fixed {
width: 100%;
height: 88rpx;
padding: 20px 0;
background: #ffffff;
}
</style>