uni-app的分包下小程式報錯app.json: [“tabBar“][1][“pagePath“]: “xxxx“ need in [“pages“]

圣迭戈發表於2024-04-22

最近接觸到一個專案,出現這樣的報錯查詢一下發現專案中分包把tabbar中的list部分pagePath寫成package_run/pages/run/run。

在tabbar中不支援這樣的。只能在pages中定義入口檔案。具體程式碼如下:

{
			"path" : "pages/run/run",//需要分包的入口只能在pages中而不是在分包的subPackages中
			"style" : 
			{
				"navigationBarTitleText" : "跑腿",
				"enablePullDownRefresh" : false
			}
		}
	],
	"subPackages": [
		{
			"root": "package_run",
			"pages": [
				{
					"path": "pages/run-orders/run-orders",
					"style": {
						"enablePullDownRefresh": false,
						"navigationBarTitleText" : "跑腿訂單"
					}
				},
				{
					"path" : "pages/join-rider/join-rider",
					"style" : 
					{
						"navigationBarTitleText" : "加入騎手",
						"enablePullDownRefresh" : false
					}
				}
			]
		}
	],
	"globalStyle": {
		// 導航欄標題顏色及狀態列前景顏色,僅支援 black/white
		"navigationBarTextStyle": "white",
		// 導航欄標題文字內容
		"navigationBarTitleText": "考拉外賣",
		// 導航欄背景顏色(同狀態列背景色)
		"navigationBarBackgroundColor": "#ffd100",
		//  下拉顯示出來的視窗的背景色
		"backgroundColor": "#F8F8F8"
	},
	"tabBar": {
		"backgroundColor": "#fff",
		"selectedColor": "#ffd100",
		"color": "#666",
		"list": [
			{
				"iconPath": "/static/icons/home.png",
				"selectedIconPath": "static/icons/home-active.png",
				"text": "首頁",
				"pagePath": "pages/index/index"
			},
			{
				"iconPath": "/static/icons/run.png",
				"selectedIconPath": "static/icons/run-selected.png",
				"text": "跑腿",
				"pagePath": "pages/run/run"
			},
			{
				"iconPath": "/static/icons/orders.png",
				"selectedIconPath": "static/icons/orders-active.png",
				"text": "訂單",
				"pagePath": "pages/orders/orders"
			},
			{
				"iconPath": "/static/icons/me.png",
				"selectedIconPath": "static/icons/me-active.png",
				"text": "我的",
				"pagePath": "pages/me/me"
			}
		]
	},

  

相關文章