当前位置:网站首页>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
边栏推荐
- Hash table, string hash (special KMP)
- MySQL deadly serial question 2 -- are you familiar with MySQL index?
- How programmers find girlfriends through blind dates
- Mobile phone battery - current market situation and future development trend
- Prose article appreciation - the rain in the warm country has never changed into cold, hard and brilliant flowers. Knowledgeable people think he is monotonous, and he thinks he is unlucky, doesn't he?
- Rearrangement of tag number of cadence OrCAD components and sequence number of schematic page
- Solution to the problem that jsp language cannot be recognized in idea
- Stringutils and collectionutils
- From the 18th line to the first line, the new story of the network security industry
- The force deduction method summarizes the single elements in the 540 ordered array
猜你喜欢
Douban scoring applet Part-3
0 basic learning C language - nixie tube dynamic scanning display
Ka! Why does the seat belt suddenly fail to pull? After reading these pictures, I can't stop wearing them
Openbionics exoskeleton project introduction | bciduino community finishing
LeetCode 168. Detailed explanation of Excel list name
Yyds dry goods inventory it's not easy to say I love you | use the minimum web API to upload files
ES6 deletes an attribute in all array objects through map, deconstruction and extension operators
Small program graduation project based on wechat examination small program graduation project opening report function reference
Example 073 square sum value judgment programming requires the input of a and B, if a ²+ b ² If the result of is greater than 100, a is output ²+ b ² Value, otherwise output the result of a + B.
Should enterprises start building progressive web applications?
随机推荐
Remember a lazy query error
Portapack application development tutorial (XVII) nRF24L01 launch C
Special copy UML notes
MySQL statement learning record
Pesticide synergist - current market situation and future development trend
Jerry's watch listens to the message notification of the target third-party software and pushes the message to the device [article]
Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
Experimental animal models - current market situation and future development trend
Should enterprises start building progressive web applications?
Solution to the problem that jsp language cannot be recognized in idea
C library function int fprintf (file *stream, const char *format,...) Send formatted output to stream
What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended
Yyds dry goods inventory it's not easy to say I love you | use the minimum web API to upload files
2022 R2 mobile pressure vessel filling certificate examination and R2 mobile pressure vessel filling simulation examination questions
Hash table, string hash (special KMP)
51 single chip microcomputer timer 2 is used as serial port
Douban scoring applet Part-3
LeetCode 168. Detailed explanation of Excel list name
I don't know why it can't run in the project and how to change it
Pyinstaller packaging py script warning:lib not found and other related issues