当前位置:网站首页>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。
边栏推荐
- 17-18. Dependency scope and life cycle plug-ins
- 校园网络问题
- centos8安装mysql.7 无法开机启动
- Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
- tars源码分析之6
- GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
- 2022 is probably the best year for the economy in the next 10 years. Did you graduate in 2022? What is the plan after graduation?
- ORICO ORICO outdoor power experience, lightweight and portable, the most convenient office charging station
- selenium驱动IE常见问题解决Message: Currently focused window has been closed.
- Redis interview question set
猜你喜欢

C实现贪吃蛇小游戏

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

Sleep quality today 78 points

leetcode825. 适龄的朋友

Mysql 45讲学习笔记(七)行锁

Native Cloud - SSH articles must be read on Cloud (used for Remote Login to Cloud Server)

Cloud native - SSH article that must be read on the cloud (commonly used for remote login to ECS)

Learn about the Internet of things protocol WiFi ZigBee Bluetooth, etc. --- WiFi and WiFi protocols start from WiFi. What do we need to know about WiFi protocol itself?

树形dp

Variables d'environnement personnalisées uniapp
随机推荐
Explain in one sentence what social proof is
Selection (023) - what are the three stages of event propagation?
Tar source code analysis Part 10
tars源码分析之5
Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
selenium驱动IE常见问题解决Message: Currently focused window has been closed.
[number theory] fast power (Euler power)
Tar source code analysis 8
同一个job有两个source就报其中一个数据库找不到,有大佬回答下吗
What is Gibson's law?
Cervical vertebra, beriberi
Reading notes of Clickhouse principle analysis and Application Practice (4)
Option (024) - do all objects have prototypes?
Variables d'environnement personnalisées uniapp
leetcode 310. Minimum Height Trees
Manually page the list (parameter list, current page, page size)
测试用例的设计
Tar source code analysis 6
Realize IIC data / instruction interaction with micro batg135
tars源码分析之3