uniapp 微信小程序自定义tabbar层级低于canvas解决方案

示例代码:

html 复制代码
<template>
	<cover-view class="tab">
		<cover-view class="navView" @tap="switc('/pages/index/index')">
			<cover-image :src="tabname ==='index'?'/static/tabbar/overide-sel.png':'/static/tabbar/overide.png'" class="navView-img"/>
			<cover-view :class="tabname ==='index'?'tabTextActive':'tabText'">数据概览</cover-view>
		</cover-view>
		<cover-view class="navView" @tap="switc('/pages/workhub/workhub')">
			<cover-image :src="tabname ==='workhub'?'/static/tabbar/workhub-sel.png':'/static/tabbar/workhub.png'" class="navView-img"/>
			<cover-view :class="tabname ==='workhub'?'tabTextActive':'tabText'">工作台</cover-view>
		</cover-view>
		<cover-view v-if="is_staff != 3" class="navView" @tap="switc('/pages/my/my')">
			<cover-image :src="tabname ==='my'?'/static/tabbar/my-sel.png':'/static/tabbar/my.png'" class="navView-img"/>
			<cover-view :class="tabname ==='my'?'tabTextActive':'tabText'">我的</cover-view>
		</cover-view>
	</cover-view>
</template>

<script>
	import { mapGetters } from 'vuex'
	export default{
		props:{
			tabname:{ type:String,default:'home' }
		},
		computed:{
			...mapGetters(['is_staff'])
		},
		mounted() {
			uni.hideTabBar({
				success() {},
				fail() {}
			})
		},
		methods:{
			switc(val){
				if(!val)return;
				uni.switchTab({url:val})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tab{
		position: fixed;
		bottom: 0;
		left: 0;
		display: flex;
		z-index: 99999 !important;
		width: 100%;
		height: 144rpx;
		background: #fff;
		box-shadow: 0rpx 0rpx 4rpx #b8b8b8;
		padding-top: 10rpx;
		.navView{
			display: flex;
			flex-direction: column;
			align-items: center;
			flex: 1;
			.navView-img{
				width: 50rpx;
				height: 50rpx;
				margin-bottom: 10rpx;
			}
			.tabText{
				font-size: 20rpx;
				color: #A5A5A5;
			}
			.tabTextActive{
				font-size: 20rpx;
				color: #FE8B1F;
			}
		}
	}
</style>

效果展示:

相关推荐
canglingyue6 分钟前
微信小程序日历事件添加实现
微信小程序·小程序
毕设源码-邱学长4 小时前
【开题答辩全过程】以 基于微信小程序校园综合服务平台的设计与实现为例,包含答辩的问题和答案
微信小程序·小程序
Thetimezipsby5 小时前
基于Taro4打造的一款最新版微信小程序、H5的多端开发简单模板
前端·javascript·微信小程序·typescript·html5·taro
從南走到北5 小时前
JAVA同城打车小程序APP打车顺风车滴滴车跑腿源码微信小程序打车源码
java·开发语言·微信·微信小程序·小程序
猫七先生7 小时前
微信小程序一键登录可行性方案
前端·微信小程序
canglingyue7 小时前
微信小程序截屏与录屏功能详解
微信小程序·小程序
吴传逞21 小时前
记一次uniapp微信小程序开发scss变量失效的问题
微信小程序·uni-app·scss
服务端技术栈1 天前
历时 1 个多月,我的第一个微信小程序「图片转 Excel」终于上线了!
前端·后端·微信小程序
2501_915921431 天前
小团队如何高效完成 uni-app iOS 上架,从分工到工具组合的实战经验
android·ios·小程序·uni-app·cocoa·iphone·webview
2501_916008891 天前
uni-app iOS 文件管理与 itools 配合实战,多工具协作的完整流程
android·ios·小程序·https·uni-app·iphone·webview