> For the complete documentation index, see [llms.txt](https://gamebox.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gamebox.gitbook.io/project/you-xi-jie-ru-wen-dang/ji-shu-dui-jie/ji-chu-neng-li/fen-bao-jia-zai.md).

# 分包加载

## 触发分包加载

```javascript
    LoadSubpackageTask loadSubpackage(Object object)
```

*参数*

* Object object: 分包加载参数和回调函数

*Object 参数*

| 属性       | 键值类型     | 是否必填 | 说明                               |
| -------- | -------- | ---- | -------------------------------- |
| name     | string   | 是    | <p>分包的名字或入口，<br>需要和分包配置中的值对应</p> |
| success  | function | 否    | 接口调用成功的回调函数                      |
| fail     | function | 否    | 接口调用失败的回调函数                      |
| complete | function | 否    | 接口调用结束的回调函数                      |

*返回值*

* LoadSubpackageTask: 加载分包任务实例，用于获取分包加载状态

## 加载分包任务实例

```javascript
    LoadSubpackageTask
```

用于获取分包加载状态

*方法*

* onProgressUpdate: 监听分包加载进度变化事件

## 监听分包加载进度变化事件

```javascript
    LoadSubpackageTask.onProgressUpdate(function callback)
```

*参数*

* callback: 监听事件的回调函数

*callback 回调函数参数*

| 属性                        | 键值类型   | 说明                    |
| ------------------------- | ------ | --------------------- |
| progress                  | number | 分包下载进度百分比             |
| totalBytesWritten         | number | 已经下载的数据长度，单位 Bytes    |
| totalBytesExpectedToWrite | number | 预期需要下载的数据总长度，单位 Bytes |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gamebox.gitbook.io/project/you-xi-jie-ru-wen-dang/ji-shu-dui-jie/ji-chu-neng-li/fen-bao-jia-zai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
