当前位置:网站首页>How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
2022-07-04 01:51:00 【Front end honest man】
One 、 Applet subcontracting
Each use subcontracting applet 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 ; and to subcontract It is divided according to the developer's configuration .
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 client will download the corresponding subcontracting , After the download is completed, it will be displayed
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 .
Click here to see the official subcontracting tutorial, which is easy to understand
Two 、uniapp Subcontracting applet
App The default is the whole package . Subcontracting configuration compatible with applets . Its purpose is not to speed up download , And for the home page is vue Start up speed at .
This is the directory structure after I subcontract the applet

- components: Common components ( For main package reference )
- page_ Those followed by pinyin are subcontractors
- In the subcontract components It is the component directory of a single subcontractor , to subcontract vue Page references can only be in their own page_zhaoshang Only in the subcontracting directory can reference
- pages It's the main package , There are startup pages /TabBar page
- static There are public static resources , Picture class
Subcontracting steps :
1. To configure manifest.json
“mp-weixin”: {
“optimization”:{“subPackages”:true}
}

Optimize subcontracting :
In the configuration of the corresponding platform (manifest.json) Add below "optimization":{"subPackages":true} Turn on subcontracting optimization
Currently only supported mp-weixin、mp-qq、mp-baidu Optimization of subcontracting
- Static files : Subcontract support static And other static resource copies , That is, static resources placed in the subcontract directory will not be packaged into the main package , It can't be used in the main package
- js file : When a js When referenced by only one subcontract , The js Will be packed into the subcontract , Otherwise, it still hits the main package ( It is referenced by the main package , Or be surpassed 1 Subcontracting references )
- Custom components : If a custom component is referenced by only one subcontract , And not put into the subcontract , Compile time will output prompt information
2. To configure pages.json
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;
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)
This step is mainly done to optimize the 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 :
| Field | type | Required | The default value is | explain |
|---|---|---|---|---|
| packages | StringArray | yes | nothing | After entering the page, pre download the subcontracted root or name.__APP__ Represents the main package . |
| network | String | no | wifi | Pre download under the specified network , Optional value is :all( It's not limited to the Internet )、wifi( only wifi Pre download ) |
app Subcontracting of , Also supports preloadRule, But the network rules are invalid .
Example :

Finally, click enter uniapp View the configuration item in the official document
Last
If it helps you , I hope I can give you a comment collection for three times !
Bloggers are honest , Answer questions for free
边栏推荐
- String hash, find the string hash value after deleting any character, double hash
- IPv6 experiment
- Idsia & supsi & usi | continuous control behavior learning and adaptive robot operation based on Reinforcement Learning
- Reading notes - learn to write: what is writing?
- In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
- Typescript basic knowledge sorting
- Avoid playing with super high conversion rate in material minefields
- Applet graduation project is based on wechat classroom laboratory reservation applet graduation project opening report function reference
- Write the first CUDA program
- 51 MCU external interrupt
猜你喜欢

Do you know the eight signs of a team becoming agile?

The reasons why QT fails to connect to the database and common solutions
![[leetcode daily question] a single element in an ordered array](/img/3a/2b465589b70cd6aeec08e79fcf40d4.jpg)
[leetcode daily question] a single element in an ordered array

Use classname to modify style properties

Avoid playing with super high conversion rate in material minefields

Maximum entropy model

From the 18th line to the first line, the new story of the network security industry

Meta metauniverse female safety problems occur frequently, how to solve the relevant problems in the metauniverse?

Conditional test, if, case conditional test statements of shell script

String & memory function (detailed explanation)
随机推荐
Small program graduation design is based on wechat order takeout small program graduation design opening report function reference
Douban scoring applet Part-3
C library function int fprintf (file *stream, const char *format,...) Send formatted output to stream
Lightweight Pyramid Networks for Image Deraining
Rearrangement of tag number of cadence OrCAD components and sequence number of schematic page
Jerry's watch information type table [chapter]
Install the pit that the electron has stepped on
File contains vulnerability summary
[turn] solve the problem of "RSA public key not find" appearing in Navicat premium 15 registration
The difference between lambda expressions and anonymous inner classes
String hash, find the string hash value after deleting any character, double hash
Who moved my code!
Meta metauniverse female safety problems occur frequently, how to solve the relevant problems in the metauniverse?
JVM performance tuning and practical basic theory - medium
Applet graduation project is based on wechat classroom laboratory reservation applet graduation project opening report function reference
Three layer switching ①
Jerry's synchronous weather information to equipment [chapter]
2020-12-02 SSM advanced integration Shang Silicon Valley
Skku| autonomous handover decision of UAV Based on deep reinforcement learning
Valentine's Day - 9 jigsaw puzzles with deep love in wechat circle of friends