uniapp 二级页面显示tabbar
时间: 2023-11-01 14:07:24 浏览: 149
在uniapp中,可以通过在App.vue中设置tabBar配置来实现二级页面显示tabbar。具体步骤如下:
1. 在App.vue中设置tabBar配置,例如:
```
<template>
<div>
<tab-bar :list="tabList" />
<router-view />
</div>
</template>
<script>
import tabBar from '@/components/tabBar.vue'
export default {
components: {
tabBar
},
data() {
return {
tabList: [
{
pagePath: '/pages/home/index',
text: '首页',
iconPath: '/static/tabbar/home.png',
selectedIconPath: '/static/tabbar/home-active.png'
},
{
pagePath: '/pages/mine/index',
text: '我的',
iconPath: '/static/tabbar/mine.png',
selectedIconPath: '/static/tabbar/mine-active.png'
}
]
}
}
}
</script>
```
2. 在二级页面中设置navigationBarTitleText和custom属性,例如:
```
<template>
<div>
<view>这是二级页面</view>
</div>
</template>
<script>
export default {
onNavigationBarButtonTap() {
uni.switchTab({
url: '/pages/home/index'
})
},
onNavigationBarTitleTap() {
uni.switchTab({
url: '/pages/home/index'
})
},
onShow() {
uni.setNavigationBarTitle({
title: '二级页面',
custom: true
})
}
}
</script>
<style>
view {
height: 100vh;
}
</style>
```
阅读全文