当前位置:网站首页>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。
边栏推荐
- 颈椎、脚气
- [number theory] fast power (Euler power)
- InputStream/OutputStream(文件的输入输出)
- tars源码分析之5
- List of top ten professional skills required for data science work
- The solution of win11 taskbar right click without Task Manager - add win11 taskbar right click function
- 1、 Relevant theories and tools of network security penetration testing
- Is the insurance annuity product worth buying? Is there a hole?
- Google Chrome Portable Google Chrome browser portable version official website download method
- MySQL 45 lecture learning notes (x) force index
猜你喜欢
2022 Xinjiang's latest eight members (Safety Officer) simulated examination questions and answers
[problem record] 03 connect to MySQL database prompt: 1040 too many connections
Fundamentals of SQL database operation
The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
The solution of win11 taskbar right click without Task Manager - add win11 taskbar right click function
selenium驱动IE常见问题解决Message: Currently focused window has been closed.
Wechat applet scroll view component scrollable view area
C language - Blue Bridge Cup - Snake filling
Download kicad on Alibaba cloud image station
Sleep quality today 78 points
随机推荐
金盾视频播放器拦截的软件关键词和进程信息
17-18. Dependency scope and life cycle plug-ins
Mysql 45讲学习笔记(七)行锁
Realize IIC data / instruction interaction with micro batg135
The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
What is the "relative dilemma" in cognitive fallacy?
Data analysis notes 09
Which water in the environment needs water quality monitoring
P26-P34 third_ template
Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
tars源码分析之9
MySQL 45 lecture learning notes (VI) global lock
tars源码分析之10
Distributed cap theory
Download kicad on Alibaba cloud image station
颈椎、脚气
运算符<< >>傻瓜式测试用例
How does the recv of TCP socket receive messages of specified length?
leetcode825. 适龄的朋友
tcp socket 的 recv 如何接收指定长度消息?