锋哥原创的uni-app视频教程:

2023版uniapp从入门到上天视频教程(Java后端无废话版),火爆更新中..._哔哩哔哩_bilibili2023版uniapp从入门到上天视频教程(Java后端无废话版),火爆更新中...共计23条视频,包括:第1讲 uni-app简介、第2讲 uni-app环境搭建、第3讲 uni-app之HelloWorld实现等,UP主更多精彩视频,请关注UP账号。uni-app tabbar组件-LMLPHPhttps://www.bilibili.com/video/BV1eG411N71c/如果应用是一个多 tab 应用,可以通过 tabBar 配置项指定一级导航栏,以及 tab 切换时显示的对应页。

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

Tips

  • 当设置 position 为 top 时,将不会显示 icon

  • tabBar 中的 list 是一个数组,只能配置最少2个、最多5个 tab,tab 按数组的顺序排序。

  • tabbar 切换第一次加载时可能渲染不及时,可以在每个tabbar页面的onLoad生命周期里先弹出一个等待雪花(hello uni-app使用了此方式)

  • tabbar 的页面展现过一次后就保留在内存中,再次切换 tabbar 页面,只会触发每个页面的onShow,不会再触发onLoad。

  • 顶部的 tabbar 目前仅微信小程序上支持。需要用到顶部选项卡的话,建议不使用 tabbar 的顶部设置,而是自己做顶部选项卡,可参考 hello uni-app->模板->顶部选项卡。

属性说明:

其中 list 接收一个数组,数组中的每个项都是一个对象,其属性值如下:

"tabBar": {
		"color": "#FF8C00",
		"selectedColor":"#B22222",
		"backgroundColor":"#FFFAFA",
		"borderStyle":"black",
		"position":"bottom",
		"list": [
			{
				"text": "主页",
				"pagePath": "pages/index/index",
				"iconPath": "static/tabbar/icon/_home.png",
				"selectedIconPath": "static/tabbar/icon/home.png"
			},
			{
				"text": "分类",
				"pagePath": "pages/classification/classification",
				"iconPath": "static/tabbar/icon/_classification.png",
				"selectedIconPath": "static/tabbar/icon/classification.png"
			},
			{
				"text": "购物车",
				"pagePath": "pages/cart/cart",
				"iconPath": "static/tabbar/icon/_cart.png",
				"selectedIconPath": "static/tabbar/icon/cart.png"
			},
			{
				"text": "我的",
				"pagePath": "pages/my/my",
				"iconPath": "static/tabbar/icon/_my.png",
				"selectedIconPath": "static/tabbar/icon/my.png"
			}
		]
	}
12-27 06:36