说明:小程序代码包单个包大小限制为2M,超过限制上传失败,如下图示
官方地址:https://developers.weixin.qq.com/miniprogram/dev/framework/subpackages/basic.html
分包步骤
1.将部分页面从pages包下取出放到分包里
2.在pages.json文件中添加配置
"subPackages": [
{
"root": "subpackage",
"pages":[
{
"path": "filling/filling",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "hsrecord/hsrecord",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "kyrecord/kyrecord",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "msgregister/msgregister",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "statistics/statistics",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "fillingrecord/fillingrecord",
"style": {
"navigationBarTitleText": ""
}
}
]
备注:"root"标签为分包根目录名称
3. 检查分包是否成功
在微信开发工具查看代码依赖分析,如下图则说明分包成功
tips:若经过分包上传仍提示包太大,则检查一下是否在运行时未选择‘运行时是否压缩代码选项’,位置:运行-->运行到小程序模拟器-->运行时是否压缩代码选项