uniapp分包预加载

uniapp实现分包预加载

pages.json中主包:

"pages": [
		{
			"path": "pages/index/index",
			"style": {
				"navigationBarTitleText": "",
				"enablePullDownRefresh": false
			  }
		}
	    ,{
            "path" : "pages/alarm/alarm",
            "style" :                                                                                    
            {
                "navigationBarTitleText": "",
                "enablePullDownRefresh": false
            }
            
        }
        ,{
            "path" : "pages/my/my",
            "style" :                                                                                    
            {
                "navigationBarTitleText": "",
                "enablePullDownRefresh": false
            }
            
        }
    ],

在pages文件夹同级目录下新建subpck存放分包
uniapp分包预加载_第1张图片
然后在pages.json中配置subPackages
uniapp分包预加载_第2张图片
代码:

"subPackages": [
		{
			"root": "subpck/my",
			"pages": [
				{
					"path": "personal",
					"style": {
						"navigationBarTitleText": "",
						"enablePullDownRefresh": false
					}
				}
			]
		}
],

最后:配置预下载分包

"preloadRule": {
		"pages/my/my": {
			"network": "all",
			"packages": [
				"subpck/my"
			]
		}
},

uniapp分包预加载_第3张图片
至此,完成分包加载!
~~写博不容易,如果觉得对你有帮助,点赞支持一下!

友情链接:解决“uniapp 分包 [获取文件失败] 以下文件已被配置忽略打包上传,模拟器无法获取”

你可能感兴趣的:(uni-app,bug解决方案,项目,uni-app)