<template>
<view>
<view class="u-page">
<!-- 所有内容的容器 -->
<Home v-if="pageFlag==='Home'"></Home>
<Console v-else-if="pageFlag==='Console'"></Console>
<Persion v-else-if="pageFlag==='Persion'"></Persion>
</view>
<!-- 与包裹页面所有内容的元素u-page同级,且在它的下方 -->
<u-tabbar :list="tarbbarPages" v-show="tarbbarShow" :before-switch="goPage">
</u-tabbar>
</view>
</template>
<script>
import Home from "./content/Home.vue"
import Console from "./content/Console.vue"
import Persion from "./content/Persion.vue"
export default {
components:{
Home,
Console,
Persion
},
data() {
return {
tarbbarPages:[],
tarbbarShow: true,
pageFlag: 'Home'
}
},
methods:{
goPage(index) {
switch(index){
case 0:this.pageFlag='Home';break;
case 1:this.pageFlag='Console';break;
case 2:this.pageFlag='Persion';break;
}
}
},
onLoad(){
console.log("导航栏-state")
console.log(this.$store.state.tabList)
this.tarbbarPages = this.$store.state.tabList;
}
}
</script>
基于uniapp+uview实现自定义导航栏
最新推荐文章于 2024-10-08 16:43:31 发布