This commit is contained in:
‘tuzi0421 2024-01-16 19:00:14 +08:00
commit a93b95e814
6 changed files with 178 additions and 16 deletions

View File

@ -4,6 +4,7 @@
console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!') console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
console.log('App Launch') console.log('App Launch')
// plus.navigator.setFullscreen(true);// // plus.navigator.setFullscreen(true);//
// uni.hideTabBar();
}, },
onShow: function() { onShow: function() {
console.log('App Show') console.log('App Show')

View File

@ -0,0 +1,147 @@
<template>
<view class="tabbar-container">
<block>
<!-- 针对中间的导航栏 通过true来判断控制类名和样式 -->
<view class="tabbar-item" v-for="(item, index) in tabbarList" :class="[item.centerItem ? 'center-item' : '']" @click="changeItem(item)" :key="index">
<view class="item-top">
<image :src="currentItem == item.id ? item.selectIcon : item.icon"></image>
</view>
<!-- 通过三元判断控制类名 达到控制选中和未选中的样式 -->
<view class="item-bottom" :class="[currentItem == item.id ? 'item-active' : '']">
<text>{{ item.text }}</text>
</view>
</view>
</block>
</view>
</template>
<script>
// easycom 使
export default {
props: {
currentPage: {
type: Number,
default: 0
}
},
data () {
return {
currentItem: 0,
tabbarList: [
{
id: 0,
path: '/pages/index/index',
icon: '/static/logo.png',
selectIcon: '/static/logo.png',
text: '首页',
centerItem: false
},
{
id: 1,
path: '/pages/person/person',
// icon: '/static/logo.png',
// selectIcon: '/static/logo.png',
text: '扫一扫',
// class
centerItem: true
},
{
id: 2,
path: '/pages/person/person',
icon: '/static/logo.png',
selectIcon: '/static/logo.png',
text: '我的',
centerItem: false
}
]
}
},
mounted () {
this.currentItem = this.currentPage
// tabBar
uni.hideTabBar()
},
methods: {
changeItem (item) {
let _this = this
//_this.currentItem = item.id;
uni.switchTab({
url: item.path
})
}
}
};
</script>
<style lang="scss" scope>
view {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.tabbar-container {
position: fixed;
bottom: 0rpx;
left: 0rpx;
width: 100%;
height: 110rpx;
box-shadow: 0 0 5px #999;
display: flex;
align-items: center;
padding: 5rpx 0;
color: #999999;
/* 针对tabbar的统一处理 */
.tabbar-item {
width: 33.33%;
height: 100rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
.item-top {
width: 70rpx;
height: 70rpx;
padding: 10rpx;
image {
width: 100%;
height: 100%;
}
}
//
.item-bottom {
font-size: 12px;
width: 100%;
}
//
.item-active {
color: #fff;
}
}
// tabbar
.center-item {
display: block;
position: relative;
.item-top {
flex-shrink: 0;
width: 100rpx;
height: 100rpx;
position: absolute;
top: -50rpx;
left: calc(50% - 50rpx);
border-radius: 50%;
box-shadow: 0 0 5px #999;
}
.item-bottom {
position: absolute;
bottom: 5rpx;
}
.item-active {
position: absolute;
bottom: 5rpx;
color: #1fff;
}
}
}
</style>

View File

@ -2,7 +2,6 @@
import "./static/iconfont/iconfont.css" import "./static/iconfont/iconfont.css"
import "./static/iconfont/iconfont-weapp/iconfont-weapp-icon.css" import "./static/iconfont/iconfont-weapp/iconfont-weapp-icon.css"
// #ifndef VUE3 // #ifndef VUE3
import Vue from 'vue' import Vue from 'vue'
import App from './App' import App from './App'
@ -28,3 +27,4 @@ export function createApp() {
} }
} }
// #endif // #endif

View File

@ -67,6 +67,7 @@
] ]
}, },
"tabBar":{ "tabBar":{
"custom":true,
"color": "#7A7E83", "color": "#7A7E83",
"selectedColor": "#3cc51f", "selectedColor": "#3cc51f",
"borderStyle": "black", "borderStyle": "black",

View File

@ -1,5 +1,6 @@
<template> <template>
<view class="home">
<view class="container home">
<view class="home_head"> <view class="home_head">
<view class="iconfont icon-chaojiguanliyuan accounticon"></view> <view class="iconfont icon-chaojiguanliyuan accounticon"></view>
<view class="name">Ykxiao 超级管理员</view> <view class="name">Ykxiao 超级管理员</view>
@ -59,13 +60,20 @@
</view> </view>
</view> </view>
</view> </view>
<tab-bar :current-page="0"></tab-bar>
</view> </view>
</template> </template>
<script> <script>
import tabBar from "@/components/customTabBar/index"
export default { export default {
components:{
tabBar
},
data() { data() {
return { return {
} }
}, },
methods: { methods: {

View File

@ -59,11 +59,16 @@
<view class="font13">系统设置</view> <view class="font13">系统设置</view>
</view> </view>
</view> </view>
<tab-bar :current-page="2"></tab-bar>
</view> </view>
</template> </template>
<script> <script>
import tabBar from "@/components/customTabBar/index"
export default { export default {
components:{
tabBar
},
data() { data() {
return { return {
} }