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

98 lines
1.9 KiB
Vue

<template>
<view>
<view class="status_bar">
<!-- 这里是状态栏 -->
</view>
<u-tabbar
:value="current"
@change="changeTab"
:fixed="true"
:placeholder="false"
:safeAreaInsetBottom="true"
:border="false"
activeColor="#FCB462"
inactiveColor="#6D6D6D"
>
<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>
import { mapGetters } from "vuex";
export default {
name: "tabBar",
props: {
currentPage: String,
},
data() {
return {
current: 0,
};
},
computed: {
...mapGetters(["tabBarList"]),
},
methods: {
changeTab(e) {
console.log(e);
console.log(this.tabBarList);
let page = "/" + this.tabBarList[e].pagePath;
console.log(page);
uni.switchTab({
url: page,
success: (res) => {
console.log(res);
},
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>
.status_bar {
height: var(--status-bar-height);
width: 100%;
}
.u-page__item__slot-icon {
width: 68rpx;
height: 68rpx;
}
.u-tabbar /deep/ .u-tabbar--fixed {
width: 92%;
padding: 9px;
background-size: 100% 100%;
bottom: 10px;
left: 1.7%;
}
</style>