微信小程序 自动解决分包大小问题_微信小程序分包加载设置
設置分包加載
微信小程序分包限制為:
主包或者單個分包最大為2M
整體小程序所有包最大為8M
為什么需要設置分包?
小程序項目中,有多種角色(公共頁面很少),設置分包加載方便管理
整個小程序壓縮后代碼大小超過2M,只能將小程序哈芬為不同的包
分包加載,在小程序啟動時,默認下載主包并啟動主包內的頁面,當用戶進入某個分包時,將對應的分包下載并啟動,優化小程序首次啟動的下載時間。
分包設置格式如下實例代碼:
"pages": [
"loading/loading" //主包
],
"subpackages": [
{
"root": "procurement", //分包名稱
"pages": [ //分包內的頁面(路徑)
"index/index",
"myPassCard/myPassCard",
"apply/apply",
"usable/usable",
"unauthorized/unauthorized",
"authdriver/authdriver",
"applicationdetails/applicationdetails",
"rejectdetail/rejectdetail",
"createInvitecode/createInvitecode"
]
},
{
"root": "driver",
"pages": [
"index/index",
"driverPassCard/driverPassCard",
"useable/useable",
"unauthorized/unauthorized",
"applicationdetails/applicationdetails",
"rejectdetail/rejectdetail",
"apply/apply",
"changeWay/changeWay"
]
},
{
"root": "rural",
"pages": [
"index/index",
"ruralPassCard/ruralPassCard",
"stayconfirm/stayconfirm",
"useable/useable",
"changeGoods/changeGoods",
"loadconfirm/loadconfirm",
"writeLoadInfo/writeLoadInfo"
]
},
{
"root": "station",
"pages": [
"index/index",
"carList/carList",
"scan/scan",
"carListDetail/carListDetail"
]
},
{
"root": "GaoGuanju",
"pages": [
"index/index",
"myPassCard/myPassCard",
"useable/useable",
"audit/audit",
"rejected/rejected",
"chart/chart",
"credit/credit",
"creditDetail/creditDetail",
"scan/scan"
]
},
{
"root": "pages",
"pages": [
"login/login",
"forgetpassword/forgetpassword",
"register/register",
"setting/setting",
"qrCode/qrCode",
"message/message",
"historycredent/historycredent",
"resetPass/resetPass",
"search/search",
"historydetail/historydetail",
"credentialUsed/credentialUsed",
"about/about",
"addGoods/addGoods",
"deal/deal",
"messageDetail/messageDetail"
]
}
],
總結
以上是生活随笔為你收集整理的微信小程序 自动解决分包大小问题_微信小程序分包加载设置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【ES6(2015)】Module模块
- 下一篇: javaweb+C+asp毕业设计项目合