当前位置:网站首页>uniapp小程序分包
uniapp小程序分包
2022-07-04 06:41:00 【天使的同类】
uniapp小程序分包
分包原因:由于微信小程序包总体积不能超过2M,这时就需要把代码进行分包处理。
主包:即放置默认启动页面/TabBar 页面,以及一些所有分包都需用到公共资源/JS 脚本;而分包则是根据pages.json的配置进行划分。
分包后的每个分包的大小是2M以内,总体积一共不能超过20M。
subPackages:分包加载配置,此配置为小程序的分包加载机制,详细请参考uniapp官网分包机制
项目目录结构如下:

需要在 pages.json 中进行代码分包处理:
{
"pages": [{
"path": "pages/index/index",
"style": {
...} //页面配置
}],
"subPackages": [{
"root": "pagesA",
"pages": [{
"path": "punchCard/index",
"style": {
...}
}]
}, {
"root": "pagesB",
"pages": [{
"path": "collectInfo/index",
"style": {
...}
}]
} //后面继续增加其他分包
],
"preloadRule": {
//分包预载配置
"pagesA/index/index": {
"network": "all",
"packages": ["__APP__"]
},
"pagesB/punchCard/index": {
"network": "all",
"packages": ["pagesA"]
}
}
}
preloadRule:配置preloadRule后,在进入小程序某个页面时,由框架自动预下载可能需要的分包,提升进入后续分包页面时的启动速度,具体请参考uniapp官网分包预载配置
There is no fate but what we make for ourselves。
边栏推荐
- Background and current situation of domestic CDN acceleration
- [problem record] 03 connect to MySQL database prompt: 1040 too many connections
- 8. Factory method
- 【问题记录】03 连接MySQL数据库提示:1040 Too many connections
- 2022, peut - être la meilleure année économique de la prochaine décennie, avez - vous obtenu votre diplôme en 2022? Comment est - ce prévu après la remise des diplômes?
- SQL join, left join, right join usage
- 校园网络问题
- [MySQL] introduction, function, creation, view, deletion and modification of database view (with exercises)
- thread priority
- uniapp 自定義環境變量
猜你喜欢

Fundamentals of SQL database operation

C réaliser des jeux de serpents gourmands

17-18. Dependency scope and life cycle plug-ins

centos8安装mysql.7 无法开机启动

How to use multithreading to export excel under massive data? Source code attached!

regular expression

27-31. Dependency transitivity, principle

GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式

The solution of win11 taskbar right click without Task Manager - add win11 taskbar right click function

selenium IDE插件下载安装使用教程
随机推荐
What is the sheji principle?
Sort list tool class, which can sort strings
Mysql 45讲学习笔记(六)全局锁
Google Chrome Portable Google Chrome browser portable version official website download method
What is tweeman's law?
抽奖系统测试报告
MySQL 45 lecture learning notes (VI) global lock
图的底部问题
C realize Snake games
Analysis of tars source code 5
17-18. Dependency scope and life cycle plug-ins
SQL injection SQL lab 11~22
Mysql 45讲学习笔记(十)force index
STM32 单片机ADC 电压计算
MySQL 45 lecture learning notes (XIV) count (*)
[number theory] fast power (Euler power)
Arcpy 利用updatelayer函数改变图层的符号系统
Redis面试题集
运算符<< >>傻瓜式测试用例
P26-P34 third_ template