当前位置:网站首页>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。
边栏推荐
- Tar source code analysis Part 7
- Selection (023) - what are the three stages of event propagation?
- The sorting in C language realizes the number sorting method from small to large
- P26-P34 third_ template
- 采用中微BATG135实现IIC数据/指令交互
- Selection (022) - what is the output of the following code?
- Bicolor case
- Tar source code analysis 9
- tars源码分析之1
- The width of the picture in rich text used by wechat applet exceeds the problem
猜你喜欢
随机推荐
List of top ten professional skills required for data science work
What is tweeman's law?
R统计绘图-随机森林分类分析及物种丰度差异检验组合图
C实现贪吃蛇小游戏
Manually page the list (parameter list, current page, page size)
Tar source code analysis Part 7
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?
《国民经济行业分类GB/T 4754—2017》官网下载地址
Mysql 45讲学习笔记(十三)表数据删掉一半,表文件大小不变
Inputstream/outputstream (input and output of file)
MySQL installation and configuration
uniapp 自定义环境变量
tcp socket 的 recv 如何接收指定长度消息?
Distributed cap theory
Mysql 45讲学习笔记(十一)字符串字段怎么加索引
Analysis of tars source code 5
Overview of convolutional neural network structure optimization
STM32 单片机ADC 电压计算
tars源码分析之5
How to use multithreading to export excel under massive data? Source code attached!