42 lines
932 B
Vue
42 lines
932 B
Vue
<template>
|
|
<view class="custom-tab-bar">
|
|
<!-- 你的tabBar布局 -->
|
|
<view v-for="(item, index) in list" :key="index" @click="switchTab(index)">
|
|
<text>{{ item.text+'111' }}</text>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
selected: 0,
|
|
list: [] // 这里应该是从uni-app获取到的tab列表
|
|
};
|
|
},
|
|
methods: {
|
|
switchTab(index) {
|
|
// 调用uni-app提供的API来切换tab
|
|
uni.switchTab({
|
|
url: `/pages/${this.list[index].pagePath}`
|
|
});
|
|
}
|
|
},
|
|
onShow() {
|
|
// 获取当前tab列表
|
|
uni.getTabBar().then(tabBar => {
|
|
this.list = tabBar.list;
|
|
// 可能还需要设置selected等
|
|
});
|
|
},
|
|
// 其他可能需要的生命周期函数...
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
/* 自定义样式 */
|
|
.custom-tab-bar {
|
|
/* ... */
|
|
}
|
|
</style> |