Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
2b6ec3b3
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
提交
2b6ec3b3
编写于
6月 16, 2022
作者:
H
HelloCrease
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update docs
Signed-off-by:
N
HelloCrease
<
lian15@huawei.com
>
上级
eedfc85b
变更
5
展开全部
显示空白变更内容
内联
并排
Showing
5 changed file
with
182 addition
and
265 deletion
+182
-265
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
+23
-72
zh-cn/application-dev/reference/apis/js-apis-mediaquery.md
zh-cn/application-dev/reference/apis/js-apis-mediaquery.md
+38
-38
zh-cn/application-dev/reference/apis/js-apis-sensor.md
zh-cn/application-dev/reference/apis/js-apis-sensor.md
+93
-127
zh-cn/application-dev/reference/apis/js-apis-system-prompt.md
...n/application-dev/reference/apis/js-apis-system-prompt.md
+8
-8
zh-cn/application-dev/reference/apis/js-apis-system-router.md
...n/application-dev/reference/apis/js-apis-system-router.md
+20
-20
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
浏览文件 @
2b6ec3b3
...
...
@@ -35,19 +35,9 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void
**示例:**
```
js
export
default
{
data
:
{
deviceIds
:
Array
,
},
callback
:
function
(
ids
)
{
this
.
deviceIds
=
ids
;
},
testGetDeviceIds
:
function
()
{
console
.
info
(
"
InputDeviceJsTest---start---testGetDeviceIds
"
);
inputDevice
.
getDeviceIds
(
this
.
callback
);
console
.
info
(
"
InputDeviceJsTest---end---testGetDeviceIds
"
);
}
}
inputDevice
.
getDeviceIds
((
ids
)
=>
{
console
.
log
(
"
The device ID list is:
"
+
ids
);
});
```
## inputDevice.getDeviceIds
...
...
@@ -61,29 +51,17 @@ function getDeviceIds(): Promise<Array\<number>>
**返回值:**
| 参数 | 说明 |
| ------------------------ | ------------------
-----------
|
| ------------------------ | ------------------ |
| Promise
\<
Array
\<
number>> | Promise实例,用于异步获取结果 |
**示例:**
```
js
export
default
{
testGetDeviceIds
:
function
()
{
console
.
info
(
"
InputDeviceJsTest---start---testGetDeviceIds
"
);
let
promise
=
inputDevice
.
getDeviceIds
();
promise
.
then
((
data
)
=>
{
console
.
info
(
'
GetDeviceIds successed, Data:
'
+
JSON
.
stringify
(
data
))
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed GetDeviceIds. Cause:
'
+
JSON
.
stringify
(
err
));
});
}
}
inputDevice
.
getDeviceIds
().
then
((
ids
)
=>
{
console
.
log
(
"
The device ID list is:
"
+
ids
);
});
```
## inputDevice.getDevice
getDevice(deviceId: number, callback: AsyncCallback
<
InputDeviceData
>
): void
...
...
@@ -102,23 +80,10 @@ getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): voi
**示例:**
```
js
export
default
{
InputDeviceData
:
{
deviceId
:
0
,
name
:
"
NA
"
,
sources
:
Array
,
axisRanges
:
Array
,
},
callback
:
function
(
deviceData
)
{
this
.
InputDeviceData
=
deviceData
;
},
testGetDevice
:
function
()
{
// 示例获取设备id为1的设备信息。
console
.
info
(
"
InputDeviceJsTest---start---testGetDevice
"
);
inputDevice
.
getDevice
(
1
,
this
.
callback
);
console
.
info
(
"
InputDeviceJsTest---end---testGetDevice
"
);
}
}
// 示例获取设备id为1的设备name信息。
inputDevice
.
getDevice
(
1
,
(
inputDevice
)
=>
{
console
.
log
(
"
The device name is:
"
+
inputDevice
.
name
);
});
```
## inputDevice.getDevice
...
...
@@ -132,30 +97,16 @@ function getDevice(deviceId: number): Promise\<InputDeviceData>
**返回值:**
| 参数 | 说明 |
| ------------------------- | ------------------
-----------
|
| ------------------------- | ------------------ |
| Promise
\<
InputDeviceData> | Promise实例,用于异步获取结果 |
**示例:**
```
js
export
default
{
InputDeviceData
:
{
deviceId
:
0
,
name
:
"
NA
"
,
sources
:
Array
,
axisRanges
:
Array
,
},
testGetDevice
:
function
()
{
// 示例获取设备id为1的设备信息。
console
.
info
(
"
InputDeviceJsTest---start---testGetDevice
"
);
let
promise
=
inputDevice
.
getDevice
(
1
);
promise
.
then
((
data
)
=>
{
console
.
info
(
'
GetDeviceId successed, Data:
'
+
JSON
.
stringify
(
data
))
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed GetDeviceId. Cause:
'
+
JSON
.
stringify
(
err
));
});
}
}
// 示例获取设备id为1的设备name信息。
inputDevice
.
getDevice
(
1
).
then
((
inputDevice
)
=>
{
console
.
log
(
"
The device name is:
"
+
inputDevice
.
name
);
});
```
...
...
@@ -190,7 +141,7 @@ export default {
**系统能力:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| ------ | ------------------------- | --------
--------
|
| ------ | ------------------------- | -------- |
| source |
[
SourceType
](
#sourcetype
)
| 轴的输入源类型。 |
| axis |
[
AxisType
](
#axistype
)
| 轴的类型 |
| max | number | 轴上报的最大值 |
...
...
zh-cn/application-dev/reference/apis/js-apis-mediaquery.md
浏览文件 @
2b6ec3b3
# 媒体查询
>

**说明:**
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 导入模块
```
```
js
import
mediaquery
from
'
@ohos.mediaquery
'
```
...
...
@@ -22,19 +22,19 @@ matchMediaSync(condition: string): MediaQueryListener
设置媒体查询的查询条件,并返回对应的监听句柄。
-
参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- |
-------- |
| condition | string | 是 | 媒体事件的匹配条件。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | --
-------- |
| condition | string | 是 | 媒体事件的匹配条件。 |
-
返回值
| 类型 | 说明 |
| -------- |
-------- |
| MediaQueryListener | 媒体事件监听句柄,用于注册和去注册监听回调。 |
**返回值:**
| 类型 | 说明 |
| ------------------ | --------------
-------- |
| MediaQueryListener | 媒体事件监听句柄,用于注册和去注册监听回调。 |
-
示例
```
listener = mediaquery.matchMediaSync('(orientation: landscape)'); //监听横屏事件
**示例:**
```
js
let
listener
=
mediaquery
.
matchMediaSync
(
'
(orientation: landscape)
'
);
//监听横屏事件
```
...
...
@@ -46,7 +46,7 @@ matchMediaSync(condition: string): MediaQueryListener
### 属性
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------
- | -------- | -------- | -------- |
-------- |
| -------
| ------- | ---- | ---- | --
-------- |
| matches | boolean | 是 | 否 | 是否符合匹配条件。 |
| media | string | 是 | 否 | 媒体事件的匹配条件。 |
...
...
@@ -57,13 +57,13 @@ on(type: 'change', callback: Callback<MediaQueryResult>): void
通过句柄向对应的查询条件注册回调,当媒体属性发生变更时会触发该回调。
-
参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- |
-------- |
| type | string | 是 | 必须填写字符串'change'。 |
| callback | Callback
<
MediaQueryResult
>
| 是 | 向媒体查询注册的回调 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | ---- | --------
-------- |
| type | string | 是 | 必须填写字符串'change'。 |
| callback | Callback
<
MediaQueryResult
>
| 是 | 向媒体查询注册的回调 |
-
示例
**示例:**
详见
[
off示例
](
#off
)
。
...
...
@@ -72,14 +72,14 @@ on(type: 'change', callback: Callback<MediaQueryResult>): void
off(type: 'change', callback?: Callback
<
MediaQueryResult
>
): void
通过句柄向对应的查询条件去注册回调,当媒体属性发生变更时不在触发指定的回调。
-
参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- |
-------- |
| type | boolean | 是 | 必须填写字符串'change'。 |
| callback | Callback
<
MediaQueryResult
>
| 否 | 需要去注册的回调,如果参数缺省则去注册该句柄下所有的回调。 |
-
示例
```
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | ---- | ---------------------
-------- |
| type | boolean | 是 | 必须填写字符串'change'。 |
| callback | Callback
<
MediaQueryResult
>
| 否 | 需要去注册的回调,如果参数缺省则去注册该句柄下所有的回调。 |
**示例:**
```
js
import
mediaquery
from
'
@ohos.mediaquery
'
let
listener
=
mediaquery
.
matchMediaSync
(
'
(orientation: landscape)
'
);
//监听横屏事件
...
...
@@ -90,8 +90,8 @@ off(type: 'change', callback?: Callback<MediaQueryResult>): void
// do something here
}
}
this.listener.on('change', this.
onPortrait) // 注册回调
this.listener.off('change', this.
onPortrait) // 去注册回调
listener
.
on
(
'
change
'
,
onPortrait
)
// 注册回调
listener
.
off
(
'
change
'
,
onPortrait
)
// 去注册回调
```
...
...
@@ -101,14 +101,14 @@ off(type: 'change', callback?: Callback<MediaQueryResult>): void
### 属性
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------
- | -------- | -------- | -------- |
-------- |
| -------
| ------- | ---- | ---- | --
-------- |
| matches | boolean | 是 | 否 | 是否符合匹配条件。 |
| media | string | 是 | 否 | 媒体事件的匹配条件。 |
### 示例
```
```
js
import
mediaquery
from
'
@ohos.mediaquery
'
let
portraitFunc
=
null
...
...
zh-cn/application-dev/reference/apis/js-apis-sensor.md
浏览文件 @
2b6ec3b3
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-system-prompt.md
浏览文件 @
2b6ec3b3
...
...
@@ -11,7 +11,7 @@
## 导入模块
```
```
js
import
prompt
from
'
@system.prompt
'
;
```
...
...
@@ -31,7 +31,7 @@ showToast(options: ShowToastOptions): void
**示例:**
```
```
js
export
default
{
showToast
()
{
prompt
.
showToast
({
...
...
@@ -60,7 +60,7 @@ showDialog(options: ShowDialogOptions): void
**示例:**
```
```
js
export
default
{
showDialog
()
{
prompt
.
showDialog
({
...
...
@@ -100,7 +100,7 @@ showActionMenu(options: ShowActionMenuOptions): void
**示例:**
```
```
js
export
default
{
showActionMenu
()
{
prompt
.
showActionMenu
({
...
...
@@ -115,11 +115,11 @@ export default {
color
:
'
#000000
'
,
},
],
success: function(
data
) {
console.log('dialog success callback,click button : ' +
data.
tapIndex);
success
:
function
(
tapIndex
)
{
console
.
log
(
'
dialog success callback,click button :
'
+
tapIndex
);
},
fail: function(
data
) {
console.log('dialog fail callback' +
data.
errMsg);
fail
:
function
(
errMsg
)
{
console
.
log
(
'
dialog fail callback
'
+
errMsg
);
},
});
}
...
...
zh-cn/application-dev/reference/apis/js-apis-system-router.md
浏览文件 @
2b6ec3b3
# 页面路由
>

**说明:**
> **说明:**
>
> - 从API Version 8 开始,该接口不再维护,推荐使用新接口[`@ohos.router`](js-apis-router.md)。
>
...
...
@@ -11,7 +11,7 @@
## 导入模块
```
```
js
import
router
from
'
@system.router
'
;
```
...
...
@@ -31,7 +31,7 @@ push(options: RouterOptions): void
**示例:**
```
```
js
// 在当前页面中
export
default
{
pushPage
()
{
...
...
@@ -49,7 +49,7 @@ export default {
```
```
```
js
// 在routerpage2页面中
export
default
{
data
:
{
...
...
@@ -85,7 +85,7 @@ replace(options: RouterOptions): void
**示例:**
```
```
js
// 在当前页面中
export
default
{
replacePage
()
{
...
...
@@ -100,7 +100,7 @@ export default {
```
```
```
js
// 在detail页面中
export
default
{
data
:
{
...
...
@@ -128,7 +128,7 @@ back(options?: BackRouterOptions): void
**示例:**
```
```
js
// index页面
export
default
{
indexPushPage
()
{
...
...
@@ -140,7 +140,7 @@ export default {
```
```
```
js
// detail页面
export
default
{
detailPushPage
()
{
...
...
@@ -152,7 +152,7 @@ export default {
```
```
```
js
// mall页面通过back,将返回detail页面
export
default
{
mallBackPage
()
{
...
...
@@ -162,7 +162,7 @@ export default {
```
```
```
js
// detail页面通过back,将返回index页面
export
default
{
defaultBack
()
{
...
...
@@ -172,7 +172,7 @@ export default {
```
```
```
js
// 通过back,返回到detail页面
export
default
{
backToDetail
()
{
...
...
@@ -208,7 +208,7 @@ clear(): void
**示例:**
```
```
js
export
default
{
clearPage
()
{
router
.
clear
();
...
...
@@ -232,7 +232,7 @@ getLength(): string
**示例:**
```
```
js
export
default
{
getLength
()
{
var
size
=
router
.
getLength
();
...
...
@@ -257,7 +257,7 @@ getState(): RouterState
**示例:**
```
```
js
export
default
{
getState
()
{
var
page
=
router
.
getState
();
...
...
@@ -284,7 +284,7 @@ enableAlertBeforeBackPage(options: EnableAlertBeforeBackPageOptions): void
**示例:**
```
```
js
export
default
{
enableAlertBeforeBackPage
()
{
router
.
enableAlertBeforeBackPage
({
...
...
@@ -292,8 +292,8 @@ export default {
success
:
function
()
{
console
.
log
(
'
success
'
);
},
fai
l: function() {
console.log('
fai
l');
cance
l
:
function
()
{
console
.
log
(
'
cance
l
'
);
},
});
}
...
...
@@ -316,15 +316,15 @@ disableAlertBeforeBackPage(options?: DisableAlertBeforeBackPageOptions): void
**示例:**
```
```
js
export
default
{
disableAlertBeforeBackPage
()
{
router
.
disableAlertBeforeBackPage
({
success
:
function
()
{
console
.
log
(
'
success
'
);
},
fai
l: function() {
console.log('
fai
l');
cance
l
:
function
()
{
console
.
log
(
'
cance
l
'
);
},
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录