uniapp(2)自定义tabbar

创建tabbar

1、系统用的tabbar

javascript 复制代码
"tabBar": {
		"selectedColor": "#00b5ff",//选中的文字颜色
		"fontSize": "20rpx",//字体大小
		"height": "130rpx",//高度
		"list": [
			{
				"pagePath":"pages/home/home",
				"text": "首页",
				"selectedIconPath": "static/ic_home_col.png",//选中的图标样式
				"iconPath": "static/ic_home_gray.png"
				
			},
			{
				"pagePath":"pages/mission/mission",
				"text": "任务广场",
				"iconPath": "static/ic_guangchang_gray.png",
				"selectedIconPath": "static/ic_guangchang_col.png"
				
			},
			{
				"pagePath": "pages/myMission/myMission",
				"text": "我的任务",
				"iconPath": "static/ic_task_gray.png",
				"selectedIconPath": "static/ic_task_col.png"
				
			},{
				"pagePath": "pages/my/my",
				"text": "我的",
				"selectedIconPath": "static/ic_mine_col.png",
				"iconPath": "static/ic_mine_gray.png"
				
			}
		]
	}

2、使用组件tabbar或者自定义tabbar

这里使用uView的自定义tabbar

在需求中,有点击选中未选中icon的样式大小,文字大小还有tabbar的高度问题,

利用view在tabbar外包一层,设置需要的高度,颜色设置成组件一致颜色

利用slot进行独立配置是否激活状态

html 复制代码
<view class="bottomBar">
		<u-tabbar :value="value" @change="name => value = name" 
:fixed="fase" :placeholder="true"
			activeColor="#00adff" 
:safeAreaInsetBottom="false">
			<u-tabbar-item text="首页">
				<view class="push_icon" slot="active-icon">
				<u-image src="/static/ic_home_col.png" 
width="16px" height="16px">
</u-image>
				</view>
				<view slot="inactive-icon">
					<u-image src="/static/ic_home_gray.png"
 width="16px" height="16px">
</u-image>
				</view>
				</u-tabbar-item>
				<u-tabbar-item text="任务广场"></u-tabbar-item>
				<u-tabbar-item text="我的任务"></u-tabbar-item>
				<u-tabbar-item text="个人中心"></u-tabbar-item>
			</u-tabbar>
	</view>

调用@change="name => value = name"为你配置的value值

使用<u-tabbar-item text="首页" @click="clicktabbar">事件进行点击匹配跳转

相关推荐
iOS阿玮15 小时前
“死了么”App荣登付费榜第一名!
uni-app·app·apple
wendycwb19 小时前
uni-app 在真机中canvas绘制的元素悬浮,内容不随父组件滚动问题
uni-app
frontend_frank20 小时前
脱离 Electron autoUpdater:uni-app跨端更新:Windows+Android统一实现方案
android·前端·javascript·electron·uni-app
三天不学习21 小时前
UniApp三端实时通信实战:SignalR在H5、APP、小程序的差异与实现
微信小程序·uni-app·signalr
念你那丝微笑21 小时前
uView Plus + Vue3 + TypeScript + UniApp 正确引入 UnoCSS(避坑版)
vue.js·typescript·uni-app
念你那丝微笑1 天前
vue3+ts在uniapp项目中实现自动导入 ref 和 reactive
vue.js·typescript·uni-app
游戏开发爱好者81 天前
如何使用 AppUploader 提交上传 iOS 应用
android·ios·小程序·https·uni-app·iphone·webview
iOS阿玮2 天前
AppStore卡审依旧存在,预计下周将逐渐恢复常态!
uni-app·app·apple
郑州光合科技余经理2 天前
开发实战:海外版同城o2o生活服务平台核心模块设计
开发语言·git·python·架构·uni-app·生活·智慧城市
行走的陀螺仪2 天前
在UniApp H5中,实现路由栈的持久化
前端·javascript·uni-app·路由持久化·路由缓存策略