[uni-app] - uni-app tabBar不显示问题

问题代码

pages.json

"tabBar":{
		"backgroundColor":"#FFFFFF",
		"color":"#000000",
		"selectedColor":"#4CD964",
		"list":[
			{
				"pagePath":"/pages/main/main",
				"text":"首页",
				"iconPath":"static/logo.png",
				"selectedIconPath":"static/logo.png"
			},
			{
				"pagePath":"/pages/index/index",
				"text":"生气",
				"iconPath":"static/logo.png",
				"selectedIconPath":"static/logo.png"
			}
		]
	}

在之后在重写该部分代码调通后,通过对比发现pagePath若是和页面路径不匹配则会出错。项目没有配置路径,因此不能通过/来代表项目根路径。通过相对路径则可以成功显示。

部分路径正确也可以显示

正确写法

"tabBar":{
		"backgroundColor":"#FFFFFF",
		"color":"#000000",
		"selectedColor":"#4CD964",
		"list":[
			{
				"pagePath":"./pages/main/main",
				"text":"首页",
				"iconPath":"static/logo.png",
				"selectedIconPath":"static/logo.png"
			},
			{
				"pagePath":"pages/index/index",
				"text":"生气",
				"iconPath":"static/logo.png",
				"selectedIconPath":"static/logo.png"
			}
		]
	}

你可能感兴趣的:(uni-app)