当前位置:网站首页>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。
边栏推荐
- How does the recv of TCP socket receive messages of specified length?
- Fundamentals of SQL database operation
- Reading notes of Clickhouse principle analysis and Application Practice (4)
- Redis面试题集
- 2022 wechat enterprise mailbox login entry introduction, how to open and register enterprise wechat enterprise mailbox?
- R statistical mapping - random forest classification analysis and species abundance difference test combination diagram
- Arcpy 利用updatelayer函数改变图层的符号系统
- 17-18. Dependency scope and life cycle plug-ins
- tars源码分析之3
- Arcpy uses the updatelayer function to change the symbol system of the layer
猜你喜欢

uniapp 自定義環境變量

C realize Snake games

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

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

云原生——上云必读之SSH篇(常用于远程登录云服务器)

Wechat applet scroll view component scrollable view area

图的底部问题

Overview of convolutional neural network structure optimization

SQL injection SQL lab 11~22

MySQL 45 lecture learning notes (VII) line lock
随机推荐
P26-P34 third_ template
What is Gibson's law?
Is the insurance annuity product worth buying? Is there a hole?
Bicolor case
Arcpy uses the updatelayer function to change the symbol system of the layer
Cervical vertebra, beriberi
Appium基础 — APPium安装(二)
Data analysis notes 09
图的底部问题
ADC voltage calculation of STM32 single chip microcomputer
What is the "relative dilemma" in cognitive fallacy?
Sleep quality today 78 points
27-31. Dependency transitivity, principle
tars源码分析之10
Tar source code analysis Part 7
Code rant: from hard coding to configurable, rule engine, low code DSL complexity clock
uniapp 自定义环境变量
ORICO ORICO outdoor power experience, lightweight and portable, the most convenient office charging station
Fundamentals of SQL database operation
Deep understanding of redis -- a new type of bitmap / hyperloglgo / Geo