当前位置:网站首页>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 :
边栏推荐
- Gee learning notes 2
- Daily question: 1175 Prime permutation
- 大家信夫一站式信用平台让信用场景“用起来
- Memory management 01 - link script
- 2022 zero code / low code development white paper [produced by partner cloud] with download
- Sum of the first n terms of Fibonacci (fast power of matrix)
- qt中uic的使用
- 代码实现MNLM
- Three talking about exception -- error handling
- 【模板】最长公共子序列 (【DP or 贪心】板子)
猜你喜欢
How to modify the error of easydss on demand service sharing time?
题解:《压缩技术》(原版、续集版)
Student course selection information management system based on ssm+jsp framework [source code + database]
能自动更新的万能周报模板,有手就会用!
[cloud native database] what to do when encountering slow SQL (Part 1)?
无向图的桥
de4000h存储安装配置
Tupang multi-target tracking! BOT sort: robust correlated multi pedestrian tracking
2022 Heilongjiang provincial examination on the writing skills of Application Essays
Qt-制作一个简单的计算器-实现四则运算-将结果以对话框的形式弹出来
随机推荐
Web Foundation
解答:EasyDSS视频点播时音频是否可以设置为默认开启?
【OpenGL】笔记二十九、高级光照(镜面高光)
Error function ERF
Explanation: here is your UFO, Goldbach conjecture
Unity skframework framework (XVII), freecameracontroller God view / free view camera control script
Redis database persistence
三谈exception——错误处理
Mysql常用命令详细大全
nohup命令
Quantum three body problem: Landau fall
P3807 [template] Lucas theorem /lucas theorem
Solve "sub number integer", "jump happily", "turn on the light"
Why can't d link DLL
运维必备——ELK日志分析系统
机器学习基础(二)——训练集和测试集的划分
Drawing Nyquist diagram with MATLAB
The xftp connection Haikang camera reported an error: the SFTP subsystem application has been rejected. Please ensure that the SFTP subsystem settings of the SSH connection are valid
Common options of tcpdump command: Three
无向图的桥