1. manifest.json 添加 subPackages属性
/* https://www.mianshigee.com/tutorial/uniapp-framework/spilt.4.2f37241983ce9c8c.md */
"mp-weixin": { /* 微信小程序特有相关 */
"appid": "wxaaa167cf9b2e2685",
"setting": {
"urlCheck": true
},
"usingComponents": true,
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"optimization": {
"subPackages": true,
"treeShaking": {
"enable": true
}
}
},
2. 创建分包,除了tarBar与tarBar对应的页面,其余的可以放子包

3. pages.json 里面配置子包
"subPackages": [
{
"root": "subPackages", // 分包1根目录
"name": "分包A", // 分包1的别名
"independent":false, // 是否是独立包(可选)
"pages": [
{
"path": "pages/test/notice",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "标题"
}
}
]
}
"preloadRule": {
"pages/homePage/homeMain": {
"network": "all",
"packages": ["subPackages"]
}
},
uni-app 框架文档 - https://www.mianshigee.com/tutorial/uniapp-framework/spilt.8.d2a784744c535c30.md