uniapp中导航栏的配置

tabBar

如果应用是一个多 tab 应用,可以通过 tabBar 配置项指定一级导航栏,以及 tab 切换时显示的对应页。

在 pages.json 中提供 tabBar 配置,不仅仅是为了方便快速开发导航,更重要的是在App和小程序端提升性能。在这两个平台,底层原生引擎在启动时无需等待js引擎初始化,即可直接读取 pages.json 中配置的 tabBar 信息,渲染原生tab。


在pages.json文件中

{
	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
		{
			"path": "pages/index/index",
			"style": {
				"navigationBarTitleText": "首页",
				"app-plus": {  
					"titleNView": false  //去掉h5顶部导航
				},
                "navigationStyle":"custom"  //可以去掉小程序端的顶部导航
			}
		},
		{
			"path": "pages/classify/classify",
			"style": {
				"navigationBarTitleText": "分类",
                   "app-plus": {
					"titleNView": {
						"titleColor": "#000",
						"buttons": [{
							"text": "搜索",
							"fontSize": "15px"
						}],
						"searchInput": {
							"backgroundColor": "rgb(240,240,240)",
							"borderRadius": "15px",
							"placeholder": "请输入品牌分类商品名称",
							"autoFocus": true
						}
					}
				}
			}
		},
		{
			"path": "pages/my/my",
			"style": {
				"navigationBarTitleText": "我的"
			}
		},
		{
			"path": "pages/shopList/shopList",
			"style": {
				"navigationBarTitleText": "商品列表"
			}
		},
		{
			"path": "pages/shopDetails/shopDetails",
			"style": {
				"navigationBarTitleText": "商品详情"
			}
		}
	],
	"globalStyle": {
		"navigationBarTextStyle": "black",
		"navigationBarTitleText": "uni-app",
		"navigationBarBackgroundColor": "#F8F8F8",
		"backgroundColor": "#F8F8F8"
	},
	"tabBar": {
		"color": "#cdcdcd",  //导航字体初始颜色
		"selectedColor": "#ff0000",  //导航字体被选中颜色
		"borderStyle": "black", //导航栏边线颜色
		"backgroundColor": "#ffffff", //导航栏背景颜色
		"list": [{
				"pagePath": "pages/index/index",
				"iconPath": "static/index.png",
				"selectedIconPath": "static/index_click.png",
				"text": "首页"
			},
			{
				"pagePath": "pages/classify/classify",
				"iconPath": "static/classify.png",
				"selectedIconPath": "static/classify_click.png",
				"text": "分类"
			},
			{
				"pagePath": "pages/my/my",
				"iconPath": "static/my.png",
				"selectedIconPath": "static/my_click.png",
				"text": "我的"
			}
		]
	}
}
document.querySelector('.uni-page-head-hd').style.display = 'none'

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值