Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
ef7a7e53
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
ef7a7e53
编写于
3月 22, 2022
作者:
O
openharmony_ci
提交者:
Gitee
3月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2334 文档更新
Merge pull request !2334 from zengyawen/master
上级
5d2c9304
cdfe53b4
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
1532 addition
and
1490 deletion
+1532
-1490
en/website.md
en/website.md
+515
-31
zh-cn/application-dev/quick-start/start-with-ets.md
zh-cn/application-dev/quick-start/start-with-ets.md
+9
-11
zh-cn/application-dev/quick-start/start-with-js-low-code.md
zh-cn/application-dev/quick-start/start-with-js-low-code.md
+2
-2
zh-cn/application-dev/quick-start/start-with-js.md
zh-cn/application-dev/quick-start/start-with-js.md
+10
-12
zh-cn/application-dev/reference/apis/Readme-CN.md
zh-cn/application-dev/reference/apis/Readme-CN.md
+1
-0
zh-cn/application-dev/reference/apis/js-apis-basic-features-pop-up.md
...ation-dev/reference/apis/js-apis-basic-features-pop-up.md
+0
-133
zh-cn/application-dev/reference/apis/js-apis-basic-features-routes.md
...ation-dev/reference/apis/js-apis-basic-features-routes.md
+0
-291
zh-cn/application-dev/reference/apis/js-apis-distributed-data.md
...pplication-dev/reference/apis/js-apis-distributed-data.md
+313
-319
zh-cn/application-dev/reference/apis/js-apis-request.md
zh-cn/application-dev/reference/apis/js-apis-request.md
+48
-48
zh-cn/application-dev/website.md
zh-cn/application-dev/website.md
+634
-643
未找到文件。
en/website.md
浏览文件 @
ef7a7e53
此差异已折叠。
点击以展开。
zh-cn/application-dev/quick-start/start-with-ets.md
浏览文件 @
ef7a7e53
...
...
@@ -21,17 +21,15 @@
## eTS工程项目文件
-
**entry**
:OpenHarmony工程模块,编译构建生成一个Hap包。
-
**entry > src > main > ets**
:用于存放ets源码。
-
**entry > src >main > ets > MainAbility**
:应用/服务的入口。
-
**entry > src >main > ets > MainAbility > pages**
:MainAbility包含的页面。
-
**entry > src >main > ets > MainAbility > app.ets**
:承载Ability生命周期。
-
**entry > src > main > resources**
:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。
-
**entry > src > main >config.json**
:模块配置文件。主要包含HAP包的配置信息、应用在具体设备上的配置信息以及应用的全局配置信息。
-
**entry > build-profile.json5**
:模块的模块信息 、编译信息配置项,包括 buildOption target配置等。
-
**entry > hvigorfile.js**
:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。
-
**src > main > ets**
:用于存放ets源码。
-
**src > main > ets > MainAbility**
:应用/服务的入口。
-
**src > main > ets > MainAbility > pages**
:MainAbility包含的页面。
-
**src > main > ets > MainAbility > app.ets**
:承载Ability生命周期。
-
**src > main > resources**
:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。
-
**src > main >config.json**
:模块配置文件。主要包含HAP包的配置信息、应用在具体设备上的配置信息以及应用的全局配置信息。
-
**build-profile.json5**
:模块的模块信息 、编译信息配置项,包括 buildOption target配置等。
-
**hvigorfile.js**
:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。
-
**build-profile.json5**
:应用级配置信息,包括签名、产品配置等。
-
**hvigorfile.js**
:应用级编译构建任务脚本。
...
...
@@ -244,4 +242,4 @@
3.
在编辑窗口右上角的工具栏,点击!
[
zh-cn_image_0000001262206247
](
figures/zh-cn_image_0000001262206247.png
)
按钮运行。效果如下图所示:
!
[
zh-cn_image_0000001217526428
](
figures/zh-cn_image_0000001217526428.png
)
恭喜您已经使用eTS语言开发完成了第一个OpenHarmony应用,
赶紧
[
探索更多的OpenHarmony功能
](
../application-dev-guide.md
)
吧。
恭喜您已经使用eTS语言开发完成了第一个OpenHarmony应用,
来
[
探索更多的OpenHarmony功能
](
../application-dev-guide.md
)
吧。
zh-cn/application-dev/quick-start/start-with-js-low-code.md
浏览文件 @
ef7a7e53
...
...
@@ -122,7 +122,7 @@ OpenHarmony低代码开发方式,具有丰富的UI界面编辑功能,遵循[
-
“
**index.viusal**
”: 打开index.visual,选中画布上的Button组件。点击右侧属性样式栏中的事件图标!
[
zh-cn_image_0000001215388136
](
figures/zh-cn_image_0000001215388136.png
)
(Events),鼠标点击Click事件的输入框,选择onclick事件,如下所示:
!
[
zh-cn_image_0000001261137889
](
figures/zh-cn_image_0000001261137889.png
)
2.
**第二个页面返回到第一个页面。**
在第二个页面中,返回按钮绑定onClick方法,点击按钮时返回到第一页。
...
...
@@ -158,4 +158,4 @@ OpenHarmony低代码开发方式,具有丰富的UI界面编辑功能,遵循[
!
[
zh-cn_image_0000001262127855
](
figures/zh-cn_image_0000001262127855.png
)
恭喜您已经使用JS语言开发(低代码方式)完成了第一个OpenHarmony应用,
赶紧
[
探索更多的OpenHarmony功能
](
../application-dev-guide.md
)
吧。
恭喜您已经使用JS语言开发(低代码方式)完成了第一个OpenHarmony应用,
来
[
探索更多的OpenHarmony功能
](
../application-dev-guide.md
)
吧。
zh-cn/application-dev/quick-start/start-with-js.md
浏览文件 @
ef7a7e53
...
...
@@ -19,18 +19,16 @@
## JS工程项目文件
-
**entry:**
OpenHarmony工程模块,编译构建生成一个Hap包。
-
**entry > src > main > js**
:用于存放js源码。
-
**entry > src >main > js > MainAbility**
:应用/服务的入口。
-
**entry > src >main > js > MainAbility > i18n**
:用于配置不同语言场景资源内容,比如应用文本词条、图片路径资源等。
-
**entry > src >main > js > MainAbility > pages**
:MainAbility包含的页面。
-
**entry > src >main >js > MainAbility > app.js**
:承载Ability生命周期。
-
**entry > src > main > resources**
:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。
-
**entry > src > main > config.json**
:模块配置文件。主要包含HAP包的配置信息、应用在具体设备上的配置信息以及应用的全局配置信息。
-
**entry > build-profile.json5**
:模块的模块信息 、编译信息配置项,包括 buildOption target配置等。
-
**entry > hvigorfile.js**
:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。
-
**src > main > js**
:用于存放js源码。
-
**src > main > js > MainAbility**
:应用/服务的入口。
-
**src > main > js > MainAbility > i18n**
:用于配置不同语言场景资源内容,比如应用文本词条、图片路径资源等。
-
**src > main > js > MainAbility > pages**
:MainAbility包含的页面。
-
**src > main > js > MainAbility > app.js**
:承载Ability生命周期。
-
**src > main > resources**
:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。
-
**src > main > config.json**
:模块配置文件。主要包含HAP包的配置信息、应用在具体设备上的配置信息以及应用的全局配置信息。
-
**build-profile.json5**
:模块的模块信息 、编译信息配置项,包括 buildOption target配置等。
-
**hvigorfile.js**
:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。
-
**build-profile.json5**
:应用级配置信息,包括签名、产品配置等。
-
**hvigorfile.js**
:应用级编译构建任务脚本。
...
...
@@ -201,4 +199,4 @@
3.
在编辑窗口右上角的工具栏,点击!
[
zh-cn_image_0000001217047316
](
figures/zh-cn_image_0000001217047316.png
)
按钮运行。效果如下图所示:
!
[
zh-cn_image_0000001217527892
](
figures/zh-cn_image_0000001217527892.png
)
恭喜您已经使用JS语言开发(传统代码方式)完成了第一个OpenHarmony应用,
赶紧
[
探索更多的OpenHarmony功能
](
../application-dev-guide.md
)
吧。
恭喜您已经使用JS语言开发(传统代码方式)完成了第一个OpenHarmony应用,
来
[
探索更多的OpenHarmony功能
](
../application-dev-guide.md
)
吧。
zh-cn/application-dev/reference/apis/Readme-CN.md
浏览文件 @
ef7a7e53
...
...
@@ -28,6 +28,7 @@
-
[
轻量级存储<sup>9+</sup>
](
js-apis-data-preferences.md
)
-
[
轻量级存储
](
js-apis-data-storage.md
)
-
[
分布式数据管理
](
js-apis-distributed-data.md
)
-
[
分布式对象
](
js-apis-data-distributedobject.md
)
-
[
关系型数据库
](
js-apis-data-rdb.md
)
-
[
结果集
](
js-apis-data-resultset.md
)
-
[
DataAbility 谓词
](
js-apis-data-ability.md
)
...
...
zh-cn/application-dev/reference/apis/js-apis-basic-features-pop-up.md
已删除
100644 → 0
浏览文件 @
5d2c9304
# 弹窗
## 导入模块
```
import prompt from '@system.prompt';
```
## 权限列表
无
## prompt.showToast
showToast(Object): void
显示文本弹窗。
-
参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| message | string | 是 | 显示的文本信息。 |
| duration | number | 否 | 默认值1500ms,建议区间:1500ms-10000ms。
<br/>
>

**说明:**
<br/>
>
若小于1500ms则取默认值,最大取值为10000ms。 |
| $
[
bottom]^{5+}$ | <length> | 否 | 设置弹窗边框距离屏幕底部的位置。<br/>> 
**说明:**
<br/>
>
仅手机和平板设备支持。 |
-
示例
```
export default {
showToast() {
prompt.showToast({
message: 'Message Info',
duration: 2000,
});
}
}
```
## prompt.showDialog
showDialog(): void
在页面内显示对话框。
-
参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| title | string | 否 | 标题文本。 |
| message | string | 否 | 内容文本。 |
| buttons | Array | 否 | 对话框中按钮的数组,结构为:{text:'button',
color:
'
\#
666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。 |
| success | Function | 否 | 接口调用成功的回调函数,返回值如success返回值所示。 |
| cancel | Function | 否 | 取消调用此接口的回调函数。 |
| complete | Function | 否 | 弹框退出时的回调函数。 |
success返回值:
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| index | number | 选中按钮在buttons数组中的索引。 |
-
示例
```
export default {
showDialog() {
prompt.showDialog({
title: 'Title Info',
message: 'Message Info',
buttons: [
{
text: 'button',
color: '#666666',
},
],
success: function(data) {
console.log('dialog success callback,click button : ' + data.index);
},
cancel: function() {
console.log('dialog cancel callback');
},
});
}
}
```
## prompt.showActionMenu<sup>6+</sup>
showActionMenu(Object): void
显示操作菜单。
-
参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| title | string | 否 | 标题文本。 |
| buttons | Array | 是 | 对话框中按钮的数组,结构为:{text:'button',
color:
'
\#
666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 |
| success | (data:
TapIndex)
=
>
void | 否 | 接口调用成功的回调函数。 |
| cancel | ()
=
>
void | 否 | 接口调用失败的回调函数。 |
| complete | ()
=
>
void | 否 | 接口调用结束的回调函数。 |
**表1**
TapIndex
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| tapIndex | number | 选中按钮在buttons数组中的索引,从0开始。 |
-
示例
```
export default {
showActionMenu() {
prompt.showActionMenu({
title: 'Title Info',
buttons: [
{
text: 'item1',
color: '#666666',
},
{
text: 'item2',
color: '#000000',
},
],
success: function(data) {
console.log('dialog success callback,click button : ' + data.tapIndex);
},
fail: function(data) {
console.log('dialog fail callback' + data.errMsg);
},
});
}
}
```
zh-cn/application-dev/reference/apis/js-apis-basic-features-routes.md
已删除
100644 → 0
浏览文件 @
5d2c9304
# 页面路由
>  **须知:**
> 页面路由需要在页面渲染完成之后才能调用,在onInit和onReady生命周期中页面还处于渲染阶段,禁止调用页面路由方法。
## 导入模块
```
import router from '@system.router';
```
## 权限列表
无
## router.push
push(Object): void
跳转到应用内的指定页面。
-
参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uri | string | 是 | 表示目标页面的uri,可以用以下两种格式:
<br/>
-
页面绝对路径,由配置文件中pages列表提供,例如:
<br/>
-
pages/index/index
<br/>
-
pages/detail/detail
<br/>
-
特殊值,如果uri的值是"/",则跳转到首页。 |
| params | Object | 否 | 跳转时要同时传递到目标页面的数据,跳转到目标页面后,参数可以在页面中直接使用,如this.data1(data1为跳转时params参数中的key值)。如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 |
-
示例
```
// 在当前页面中
export default {
pushPage() {
router.push({
uri: 'pages/routerpage2/routerpage2',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
},
},
});
}
}
```
```
// 在routerpage2页面中
export default {
data: {
data1: 'default',
data2: {
data3: [1, 2, 3]
}
},
onInit() {
console.info('showData1:' + this.data1);
console.info('showData3:' + this.data2.data3);
}
}
```
>  **说明:**
> 页面路由栈支持的最大Page数量为32。
## router.replace
replace(Object): void
用应用内的某个页面替换当前页面,并销毁被替换的页面。
-
参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uri | string | 是 | 目标页面的uri,可以是以下的两种格式:
<br/>
-
页面绝对路径,由配置文件中pages列表提供,例如:
<br/>
-
pages/index/index
<br/>
-
pages/detail/detail
<br/>
-
特殊值,如果uri的值是"/",则跳转到首页。 |
| params | Object | 否 | 跳转时要同时传递到目标页面的数据,跳转到目标页面后,参数可以在页面中直接使用,如this.data1(data1为跳转时params参数中的key值)。如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 |
-
示例
```
// 在当前页面中
export default {
replacePage() {
router.replace({
uri: 'pages/detail/detail',
params: {
data1: 'message',
},
});
}
}
```
```
// 在detail页面中
export default {
data: {
data1: 'default'
},
onInit() {
console.info('showData1:' + this.data1)
}
}
```
## router.back
back(Object): void
返回上一页面或指定的页面。
-
参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uri | string | 否 | 返回到指定uri的界面,如果页面栈上没有uri页面,则不响应该情况。如果uri未设置,则返回上一页。 |
-
示例
```
// index页面
export default {
indexPushPage() {
router.push({
uri: 'pages/detail/detail',
});
}
}
```
```
// detail页面
export default {
detailPushPage() {
router.push({
uri: 'pages/mall/mall',
});
}
}
```
```
// mall页面通过back,将返回detail页面
export default {
mallBackPage() {
router.back();
}
}
```
```
// detail页面通过back,将返回index页面
export default {
defaultBack() {
router.back();
}
}
```
```
// 通过back,返回到detail页面
export default {
backToDetail() {
router.back({uri:'pages/detail/detail'});
}
}
```
>  **说明:**
> 示例中的uri字段是页面路由,由配置文件中的pages列表指定。
## router.clear
clear(): void
清空页面栈中的所有历史页面,仅保留当前页面作为栈顶页面。
-
示例
```
export default {
clearPage() {
router.clear();
}
}
```
## router.getLength
getLength(): string
获取当前在页面栈内的页面数量。
-
返回值
| 类型 | 说明 |
| -------- | -------- |
| string | 页面数量,页面栈支持最大数值是32。 |
-
示例
```
export default {
getLength() {
var size = router.getLength();
console.log('pages stack size = ' + size);
}
}
```
## router.getState
getState():
<
RouterState
>
获取当前页面的状态信息。
-
返回值
**表1**
RouterState
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| index | number | 表示当前页面在页面栈中的索引。
<br/>
>

**说明:**
<br/>
>
从栈底到栈顶,index从1开始递增。 |
| name | string | 表示当前页面的名称,即对应文件名。 |
| path | string | 表示当前页面的路径。 |
-
示例
```
export default {
getState() {
var page = router.getState();
console.log('current index = ' + page.index);
console.log('current name = ' + page.name);
console.log('current path = ' + page.path);
}
}
```
## router.enableAlertBeforeBackPage<sup>6+</sup>
enableAlertBeforeBackPage(Object): void
开启页面返回询问对话框。
-
参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| message | string | 是 | 询问对话框内容。 |
| success | ()
=
>
void | 否 | 接口调用成功的回调函数。 |
| fail | ()
=
>
void | 否 | 接口调用失败的回调函数。 |
| complete | ()
=
>
void | 否 | 接口调用结束的回调函数。 |
-
示例
```
export default {
enableAlertBeforeBackPage() {
router.enableAlertBeforeBackPage({
message: 'Message Info',
success: function() {
console.log('success');
},
fail: function() {
console.log('fail');
},
});
}
}
```
## router.disableAlertBeforeBackPage<sup>6+</sup>
disableAlertBeforeBackPage(Object): void
禁用页面返回询问对话框。
-
参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| success | ()
=
>
void | 否 | 接口调用成功的回调函数。 |
| fail | ()
=
>
void | 否 | 接口调用失败的回调函数。 |
| complete | ()
=
>
void | 否 | 接口调用结束的回调函数。 |
-
示例
```
export default {
disableAlertBeforeBackPage() {
router.disableAlertBeforeBackPage({
success: function() {
console.log('success');
},
fail: function() {
console.log('fail');
},
});
}
}
```
zh-cn/application-dev/reference/apis/js-apis-distributed-data.md
浏览文件 @
ef7a7e53
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-request.md
浏览文件 @
ef7a7e53
...
...
@@ -126,7 +126,7 @@ upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void
### on('progress')
on(type: 'progress', callback:
AsyncCallback
<
uploadedSize: number, totalSize: number
>
=
>
void): void
on(type: 'progress', callback:
(uploadedSize: number, totalSize: number)
=
>
void): void
开启上传任务监听,异步方法,使用callback形式返回结果。
...
...
@@ -142,10 +142,10 @@ on(type: 'progress', callback:AsyncCallback <uploadedSize: number, totalSize:
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
| uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
-
示例:
...
...
@@ -159,7 +159,7 @@ on(type: 'progress', callback:AsyncCallback <uploadedSize: number, totalSize:
### on('headerReceive')<sup>7+</sup>
on(type: 'headerReceive', callback:
AsyncCallback
<
object
>
=
>
void): void
on(type: 'headerReceive', callback:
(header: object)
=
>
void): void
开启上传任务监听,异步方法,使用callback形式返回结果。
...
...
@@ -171,13 +171,13 @@ on(type: 'headerReceive', callback: AsyncCallback<object> => void): voi
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 订阅的事件类型,取值为'headerReceive'(接收响应头)。 |
| callback |
AsyncCallback
<
object
>
| 是 | HTTP
Response
Header事件的回调函数。 |
| callback |
header:
object
| 是 | HTTP
Response
Header事件的回调函数。 |
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| header
s | object | 是 | HTTP
Response
Header。 |
| header
| object | 是 | HTTP
Response
Header。 |
-
示例:
...
...
@@ -191,7 +191,7 @@ on(type: 'headerReceive', callback: AsyncCallback<object> => void): voi
### off('progress')
off(type:
'progress', callback:AsyncCallback
<
uploadedSize: number, totalSize: number
>
=
>
void): void
off(type:
'progress', callback?: (uploadedSize: number, totalSize: number) =
>
void): void
关闭上传任务监听,异步方法,使用callback形式返回结果。
...
...
@@ -207,10 +207,10 @@ off(type: 'progress', callback:AsyncCallback<uploadedSize: number, totalSize:
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
| uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 |
| totalSize | number | 是 | 上传文件的总大小,单位为KB。 |
-
示例:
...
...
@@ -224,7 +224,7 @@ off(type: 'progress', callback:AsyncCallback<uploadedSize: number, totalSize:
### off('headerReceive')<sup>7+</sup>
off(type: 'headerReceive', callback
:AsyncCallback
<
object
>
=
>
void): void
off(type: 'headerReceive', callback
?: (header: object)
=
>
void): void
关闭上传任务监听,异步方法,使用callback形式返回结果。
...
...
@@ -236,13 +236,13 @@ off(type: 'headerReceive', callback:AsyncCallback<object> => void): voi
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 取消订阅的事件类型,取值为'headerReceive'(接收响应头)。 |
| callback |
AsyncCallback
<
object
>
| 否 | HTTP
Response
Header事件的回调函数。 |
| callback |
header:
object
| 否 | HTTP
Response
Header事件的回调函数。 |
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| header
s | object | 是 | HTTP
Response
Header。 |
| header
| object | 是 | HTTP
Response
Header。 |
-
示例:
...
...
@@ -337,7 +337,7 @@ remove(callback: AsyncCallback<boolean>): void
| -------- | -------- | -------- | -------- |
| filename | string | 否 | multipart提交时,请求头中的文件名。 |
| name | string | 否 | multipart提交时,表单项目的名称,缺省为file。 |
| ur
l
| string | 是 | 文件的本地存储路径。
<br/>
支持“dataability”和“internal”两种协议类型,但“internal”仅支持临时目录,示例:
<br/>
dataability:///com.domainname.dataability.persondata/person/10/file.txt
<br/>
internal://cache/path/to/file.txt |
| ur
i
| string | 是 | 文件的本地存储路径。
<br/>
支持“dataability”和“internal”两种协议类型,但“internal”仅支持临时目录,示例:
<br/>
dataability:///com.domainname.dataability.persondata/person/10/file.txt
<br/>
internal://cache/path/to/file.txt |
| type | string | 否 | 文件的内容类型,默认根据文件名或路径的后缀获取。 |
...
...
@@ -419,7 +419,7 @@ download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): v
### on('progress')
on(type: 'progress', callback:
AsyncCallback
<
receivedSize: number, totalSize: number
>
=
>
void): void
on(type: 'progress', callback:
(receivedSize: number, totalSize: number)
=
>
void): void
开启下载任务监听,异步方法,使用callback形式返回结果。
...
...
@@ -435,10 +435,10 @@ on(type: 'progress', callback:AsyncCallback<receivedSize: number, totalSize:
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| receivedSize | number | 是 | 当前下载的进度,单位为KB。 |
| totalSize | number | 是 | 下载文件的总大小,单位为KB。 |
| receivedSize | number | 是 | 当前下载的进度,单位为KB。 |
| totalSize | number | 是 | 下载文件的总大小,单位为KB。 |
-
示例:
...
...
@@ -459,7 +459,7 @@ on(type: 'progress', callback:AsyncCallback<receivedSize: number, totalSize:
### off('progress')
off(type: 'progress', callback
: AsyncCallback
<
receivedSize: number, totalSize: number
>
=
>
void): void
off(type: 'progress', callback
?: (receivedSize: number, totalSize: number)
=
>
void): void
关闭下载任务监听,异步方法,使用callback形式返回结果。
...
...
@@ -475,10 +475,10 @@ off(type: 'progress', callback: AsyncCallback<receivedSize: number, totalSize
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| receivedSize | number | 是 | 当前下载的进度。 |
| totalSize | number | 是 | 下载文件的总大小。 |
| receivedSize | number | 是 | 当前下载的进度。 |
| totalSize | number | 是 | 下载文件的总大小。 |
-
示例:
...
...
@@ -499,7 +499,7 @@ off(type: 'progress', callback: AsyncCallback<receivedSize: number, totalSize
### on('complete')<sup>7+</sup>
on(type: 'complete', callback:
AsyncCallback
<>
=
>
void): void
on(type: 'complete', callback:
()
=
>
void): void
开启下载任务完成监听,异步方法,使用callback形式返回。
...
...
@@ -532,7 +532,7 @@ on(type: 'complete', callback:AsyncCallback<> => void): void
### off('complete')<sup>7+</sup>
off(type: 'complete', callback
:AsyncCallback
<>
=
>
void): void
off(type: 'complete', callback
?:()
=
>
void): void
取消下载任务完成监听,异步方法,使用callback形式返回。
...
...
@@ -565,7 +565,7 @@ off(type: 'complete', callback:AsyncCallback<> => void): void
### on('fail')<sup>7+</sup>
on(type: 'fail', callback:
AsyncCallback
<
err: number
>
=
>
void): void
on(type: 'fail', callback:
(err: number)
=
>
void): void
开启下载任务失败监听,异步方法,使用callback形式返回结果。
...
...
@@ -581,9 +581,9 @@ on(type: 'fail', callback:AsyncCallback<err: number> => void): void
回调函数的参数:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| err | number | 是 | 下载失败的错误码,错误原因见
[
ERROR.*
](
#常量
)
。 |
| err | number | 是 | 下载失败的错误码,错误原因见
[
ERROR.*
](
#常量
)
。 |
-
示例
...
...
@@ -604,7 +604,7 @@ on(type: 'fail', callback:AsyncCallback<err: number> => void): void
### off('fail')<sup>7+</sup>
off(type: 'fail', callback
:AsyncCallback
<
err: number
>
=
>
void): void
off(type: 'fail', callback
?: (err: number)
=
>
void): void
取消下载任务失败监听,异步方法,使用callback形式返回结果。
...
...
@@ -620,9 +620,9 @@ off(type: 'fail', callback:AsyncCallback<err: number> => void): void
回调函数的参数
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| err | number | 是 | 下载失败的错误码。错误原因见
[
ERROR_*
](
#常量
)
。 |
| err | number | 是 | 下载失败的错误码。错误原因见
[
ERROR_*
](
#常量
)
。 |
-
示例
...
...
@@ -643,7 +643,7 @@ off(type: 'fail', callback:AsyncCallback<err: number> => void): void
### on('pause')<sup>7+</sup>
on(type: 'pause', callback:
AsyncCallback
<>
=
>
void): void
on(type: 'pause', callback:
()
=
>
void): void
开启下载任务暂停监听,异步方法,使用callback形式返回结果。
...
...
@@ -676,7 +676,7 @@ on(type: 'pause', callback:AsyncCallback<> => void): void
### off('pause')<sup>7+</sup>
off(type: 'pause', callback
:AsyncCallback
<>
=
>
void): void
off(type: 'pause', callback
?:()
=
>
void): void
取消下载任务暂停监听,异步方法,使用callback形式返回结果。
...
...
@@ -709,7 +709,7 @@ off(type: 'pause', callback:AsyncCallback<> => void): void
### on('remove')<sup>7+</sup>
on(type: 'remove', callback:
AsyncCallback
<>
=
>
void): void
on(type: 'remove', callback:
()
=
>
void): void
开启下载任务移除监听,异步方法,使用callback形式返回结果。
...
...
@@ -742,7 +742,7 @@ on(type: 'remove', callback:AsyncCallback<> => void): void
### off('remove')<sup>7+</sup>
off(type: 'remove', callback
:AsyncCallback
<>
=
>
void): void
off(type: 'remove', callback
?:()
=
>
void): void
取消下载任务移除监听,异步方法,使用callback形式返回结果。
...
...
@@ -847,7 +847,7 @@ query(): Promise<DownloadInfo>
-
参数:
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
[DownloadInfo](#downloadinfo)
>
| 查询下载任务信息。 |
| Promise
<
[DownloadInfo](#downloadinfo
7
)
>
| 查询下载任务信息。 |
-
示例
...
...
@@ -873,7 +873,7 @@ query(callback: AsyncCallback<DownloadInfo>): void
-
参数:
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
[DownloadInfo](#downloadinfo)
>
| 是 | 查询下载任务的回调函数。 |
| callback | AsyncCallback
<
[DownloadInfo](#downloadinfo
7
)
>
| 是 | 查询下载任务的回调函数。 |
-
示例:
...
...
@@ -944,7 +944,7 @@ queryMimeType(callback: AsyncCallback<string>): void;
### pause<sup>7+</sup>
pause(): Promise
<
boolean
>
pause(): Promise
<
void
>
暂停下载任务,异步方法,使用promise形式返回结果。
...
...
@@ -955,7 +955,7 @@ pause(): Promise<boolean>
-
返回值:
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
boolean
>
| 暂停下载任务是否成功。 |
| Promise
<
void
>
| 暂停下载任务是否成功。 |
-
示例
...
...
@@ -974,7 +974,7 @@ pause(): Promise<boolean>
### pause<sup>7+</sup>
pause(callback: AsyncCallback
<
boolean
>
): void
pause(callback: AsyncCallback
<
void
>
): void
暂停下载任务,异步方法,使用callback形式返回结果。
...
...
@@ -985,7 +985,7 @@ pause(callback: AsyncCallback<boolean>): void
-
参数
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
boolean
>
| 是 | 暂停下载任务的回调函数。 |
| callback | AsyncCallback
<
void
>
| 是 | 暂停下载任务的回调函数。 |
-
示例
...
...
@@ -1006,7 +1006,7 @@ pause(callback: AsyncCallback<boolean>): void
### resume<sup>7+</sup>
resume(): Promise
<
boolean
>
resume(): Promise
<
void
>
重新启动暂停的下载任务,异步方法,使用promise形式返回结果。
...
...
@@ -1017,7 +1017,7 @@ resume(): Promise<boolean>
-
参数:
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
boolean
>
| 重新启动暂停的下载任务是否成功。 |
| Promise
<
void
>
| 重新启动暂停的下载任务是否成功。 |
-
示例
...
...
@@ -1037,7 +1037,7 @@ resume(): Promise<boolean>
### resume<sup>7+</sup>
resume(callback: AsyncCallback
<
boolean
>
): void
resume(callback: AsyncCallback
<
void
>
): void
重新启动暂停的下载任务,异步方法,使用callback形式返回结果。
...
...
@@ -1048,7 +1048,7 @@ resume(callback: AsyncCallback<boolean>): void
-
参数
| 参数名 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
boolean
>
| 是 | 重新启动暂停的下载任务的回调函数。 |
| callback | AsyncCallback
<
void
>
| 是 | 重新启动暂停的下载任务的回调函数。 |
-
示例
...
...
@@ -1083,7 +1083,7 @@ resume(callback: AsyncCallback<boolean>): void
| title | string | 否 | 设置下载会话标题。 |
## DownloadInfo
## DownloadInfo
<sup>7+</sup>
**系统能力**
: SystemCapability.MiscServices.Download
...
...
zh-cn/application-dev/website.md
浏览文件 @
ef7a7e53
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录