当前位置:网站首页>Subcontracting configuration of uniapp applet subpackages
Subcontracting configuration of uniapp applet subpackages
2022-07-02 13:45:00 【Lao Zhang typed the code online】
Use scenarios :
uniapp When developing various small programs, the main package is too large , Unable to upload
There is an option in the developer tool for testing , Can increase the subcontracting size
Subcontracting mechanism
When the applet starts , By default, the main package will be downloaded and the page in the main package will be started , When the user enters a page in the subcontract , The corresponding subcontracting will be downloaded automatically , After the download is completed, it will be displayed .
Every applet that uses subcontracting must contain a main package . The so-called main package , That is, the default startup page /TabBar page , And some public resources are required for all subcontracts /JS Script ; Subcontracting is divided according to the configuration of developers .
At present, there are the following restrictions on the size of small package :
The size of all packets of the whole small program shall not exceed 20M
Single subcontract / The main packet size cannot exceed 2M
Subcontracting the applet , Can optimize the download time of the first start of the applet , And better decouple and collaborate when multiple teams work together .
Independent services are supported under subcontracting file Catalog , Used to subcontract static resources .

This is the normal component directory 
1. First , stay uniapp There was already one in the structure pages My bag ( Folder ) 了 , At this time pages Create a new one in the same level subpkg(commission) package And create a new page
2. To configure pages.json( Native applets need to app.json To configure )
stay pages.json Create a new array in "subPackages", The array contains two parameters :1.root: Is the root directory of the sub package ,2.pages: Which pages does the sub package consist of , The parameters are the same as pages;
"subpackages": [
{
"root": "commission/",
"pages": [
{
"path" : "pages/index",
"style" :
{
"navigationBarTitleText": " My earnings ",
"enablePullDownRefresh": false
}
},{
"path" : "pages/poster/index",
"style" :
{
"navigationBarTitleText": " Invite friends ",
"enablePullDownRefresh": false
}
},{
"path" : "pages/down/index",
"style" :
{
"navigationBarTitleText": " The friends list ",
"enablePullDownRefresh": false
}
},{
"path" : "pages/count/index",
"style" :
{
"navigationBarTitleText": " Data statistics ",
"navigationStyle": "custom" ,
"enablePullDownRefresh": false
}
}
]
}
],
Be careful : The main package and subcontract cannot be in the same directory , In the build uniapp Project time , Consider the directory structure , For subcontracting later ;
3. Subcontract preload configuration (preloadRule)
Mainly to optimize speed , If you don't want to optimize the speed, you can skip this configuration
To configure preloadRule after , When entering a page of the applet , The framework automatically pre downloads the subcontracts that may be required , Increase the startup speed when entering the subsequent subcontracting page
preloadRule in ,key It's the page path ,value Is the pre download configuration to enter this page , Each configuration has the following items :

边栏推荐
- Why is the default of switch followed by break?
- (POJ - 1984) navigation nightare (weighted and search set)
- When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
- leetcode621. task scheduler
- 文件的下载与图片的预览
- Daily question: 1175 Prime permutation
- mac(macos Monterey12.2 m1) 个人使用php开发
- Winter vacation daily question - lucky numbers in the matrix
- We sincerely invite young creators to share with investors and entrepreneurs how to make choices in life in the metauniverse
- 科技的成就(二十七)
猜你喜欢

无向图的桥

Don't spend money, spend an hour to build your own blog website

Redis数据库持久化

错误:EACCES:权限被拒绝,访问“/usr/lib/node_modules”

Crowncad (crown CAD), the first fully independent 3D CAD platform based on Cloud Architecture in China

We sincerely invite young creators to share with investors and entrepreneurs how to make choices in life in the metauniverse

de4000h存储安装配置

题解:《你的飞碟在这儿》、《哥德巴赫猜想》

大家信夫一站式信用平台让信用场景“用起来

【蓝桥杯选拔赛真题43】Scratch航天飞行 少儿编程scratch蓝桥杯选拔赛真题讲解
随机推荐
Dingtalk 发送消息
Student course selection information management system based on ssm+jsp framework [source code + database]
互联网常见34个术语解释
Sum of the first n terms of Fibonacci (fast power of matrix)
nohup命令
Web基础
Pocket Raider comments
无向图的桥
Professor of Shanghai Jiaotong University: he Yuanjun - bounding box (containment / bounding box)
What are eNB, EPC and PGW?
Unity small map production [2]
How to use SAP's metadata framework (MDF) to build custom business rules?
JS reverse massive creative signature
Performance optimization of memory function
Why can't d link DLL
mysql ---- Oracle中的rownum转换成MySQL
Runhe hi3516 development board openharmony small system and standard system burning
能自动更新的万能周报模板,有手就会用!
Unity skframework framework (XIX), POI points of interest / information points
We sincerely invite young creators to share with investors and entrepreneurs how to make choices in life in the metauniverse

