Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
6acf3db4
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
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看板
提交
6acf3db4
编写于
5月 11, 2022
作者:
Z
zengyawen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update docs
Signed-off-by:
N
zengyawen
<
zengyawen1@huawei.com
>
上级
a1802626
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
302 addition
and
302 deletion
+302
-302
zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
...plication-dev/reference/apis/js-apis-abilityAccessCtrl.md
+8
-8
zh-cn/application-dev/reference/apis/js-apis-call.md
zh-cn/application-dev/reference/apis/js-apis-call.md
+18
-18
zh-cn/application-dev/reference/apis/js-apis-contact.md
zh-cn/application-dev/reference/apis/js-apis-contact.md
+79
-79
zh-cn/application-dev/reference/apis/js-apis-convertxml.md
zh-cn/application-dev/reference/apis/js-apis-convertxml.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-faultLogger.md
zh-cn/application-dev/reference/apis/js-apis-faultLogger.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-http.md
zh-cn/application-dev/reference/apis/js-apis-http.md
+12
-12
zh-cn/application-dev/reference/apis/js-apis-net-connection.md
.../application-dev/reference/apis/js-apis-net-connection.md
+30
-30
zh-cn/application-dev/reference/apis/js-apis-observer.md
zh-cn/application-dev/reference/apis/js-apis-observer.md
+18
-18
zh-cn/application-dev/reference/apis/js-apis-radio.md
zh-cn/application-dev/reference/apis/js-apis-radio.md
+19
-19
zh-cn/application-dev/reference/apis/js-apis-request.md
zh-cn/application-dev/reference/apis/js-apis-request.md
+11
-11
zh-cn/application-dev/reference/apis/js-apis-sim.md
zh-cn/application-dev/reference/apis/js-apis-sim.md
+20
-20
zh-cn/application-dev/reference/apis/js-apis-sms.md
zh-cn/application-dev/reference/apis/js-apis-sms.md
+11
-11
zh-cn/application-dev/reference/apis/js-apis-socket.md
zh-cn/application-dev/reference/apis/js-apis-socket.md
+39
-39
zh-cn/application-dev/reference/apis/js-apis-system-cipher.md
...n/application-dev/reference/apis/js-apis-system-cipher.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-telephony-data.md
.../application-dev/reference/apis/js-apis-telephony-data.md
+11
-11
zh-cn/application-dev/reference/apis/js-apis-webSocket.md
zh-cn/application-dev/reference/apis/js-apis-webSocket.md
+19
-19
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
浏览文件 @
6acf3db4
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
## 导入模块
## 导入模块
```
```
js
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
```
```
...
@@ -26,7 +26,7 @@ createAtManager(): AtManager
...
@@ -26,7 +26,7 @@ createAtManager(): AtManager
**示例:**
**示例:**
```
```
js
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
```
```
...
@@ -57,7 +57,7 @@ verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStat
...
@@ -57,7 +57,7 @@ verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStat
**示例:**
**示例:**
```
```
js
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
let
tokenID
=
0
;
let
tokenID
=
0
;
let
promise
=
AtManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
);
let
promise
=
AtManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
);
...
@@ -92,7 +92,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl
...
@@ -92,7 +92,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl
**示例:**
**示例:**
```
```
js
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
let
tokenID
=
0
;
let
tokenID
=
0
;
let
promise
=
AtManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
);
let
promise
=
AtManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
);
...
@@ -124,7 +124,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl
...
@@ -124,7 +124,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl
**示例:**
**示例:**
```
```
js
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
let
tokenID
=
0
;
let
tokenID
=
0
;
let
permissionFlag
=
1
;
let
permissionFlag
=
1
;
...
@@ -159,7 +159,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF
...
@@ -159,7 +159,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF
**示例:**
**示例:**
```
```
js
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
let
tokenID
=
0
;
let
tokenID
=
0
;
let
permissionFlag
=
1
;
let
permissionFlag
=
1
;
...
@@ -190,7 +190,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF
...
@@ -190,7 +190,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF
**示例:**
**示例:**
```
```
js
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
let
tokenID
=
0
;
let
tokenID
=
0
;
AtManager
.
revokeUserGrantedPermission
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
,
permissionFlag
,
data
=>
{
AtManager
.
revokeUserGrantedPermission
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
,
permissionFlag
,
data
=>
{
...
@@ -223,7 +223,7 @@ getPermissionFlags(tokenID: number, permissionName: string): Promise<number&g
...
@@ -223,7 +223,7 @@ getPermissionFlags(tokenID: number, permissionName: string): Promise<number&g
**示例:**
**示例:**
```
```
js
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
var
AtManager
=
abilityAccessCtrl
.
createAtManager
();
let
tokenID
=
0
;
let
tokenID
=
0
;
let
promise
=
AtManager
.
getPermissionFlags
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
);
let
promise
=
AtManager
.
getPermissionFlags
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
);
...
...
zh-cn/application-dev/reference/apis/js-apis-call.md
浏览文件 @
6acf3db4
...
@@ -30,7 +30,7 @@ dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void
...
@@ -30,7 +30,7 @@ dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void
**示例:**
**示例:**
```
```
js
call
.
dial
(
"
138xxxxxxxx
"
,
(
err
,
data
)
=>
{
call
.
dial
(
"
138xxxxxxxx
"
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -57,7 +57,7 @@ dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean
...
@@ -57,7 +57,7 @@ dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean
**示例:**
**示例:**
```
```
js
call
.
dial
(
"
138xxxxxxxx
"
,
{
call
.
dial
(
"
138xxxxxxxx
"
,
{
extras
:
false
extras
:
false
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -91,7 +91,7 @@ dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\>
...
@@ -91,7 +91,7 @@ dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\>
**示例:**
**示例:**
```
```
js
let
promise
=
call
.
dial
(
"
138xxxxxxxx
"
,
{
let
promise
=
call
.
dial
(
"
138xxxxxxxx
"
,
{
extras
:
false
extras
:
false
});
});
...
@@ -121,7 +121,7 @@ makeCall(phoneNumber: string, callback: AsyncCallback\<void\>): void
...
@@ -121,7 +121,7 @@ makeCall(phoneNumber: string, callback: AsyncCallback\<void\>): void
**示例:**
**示例:**
```
```
js
call
.
makeCall
(
"
138xxxxxxxx
"
,
err
=>
{
call
.
makeCall
(
"
138xxxxxxxx
"
,
err
=>
{
console
.
log
(
`makeCall callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`makeCall callback: err->
${
JSON
.
stringify
(
err
)}
`
);
});
});
...
@@ -152,7 +152,7 @@ makeCall(phoneNumber: string): Promise\<void\>
...
@@ -152,7 +152,7 @@ makeCall(phoneNumber: string): Promise\<void\>
**示例:**
**示例:**
```
```
js
let
promise
=
call
.
makeCall
(
"
138xxxxxxxx
"
);
let
promise
=
call
.
makeCall
(
"
138xxxxxxxx
"
);
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
console
.
log
(
`makeCall success`
);
console
.
log
(
`makeCall success`
);
...
@@ -177,7 +177,7 @@ hasCall\(callback: AsyncCallback<boolean\>\): void
...
@@ -177,7 +177,7 @@ hasCall\(callback: AsyncCallback<boolean\>\): void
**示例:**
**示例:**
```
```
js
call
.
hasCall
((
err
,
data
)
=>
{
call
.
hasCall
((
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -200,7 +200,7 @@ hasCall\(\): Promise<boolean\>
...
@@ -200,7 +200,7 @@ hasCall\(\): Promise<boolean\>
**示例:**
**示例:**
```
```
js
let
promise
=
call
.
hasCall
();
let
promise
=
call
.
hasCall
();
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`hasCall success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`hasCall success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -226,7 +226,7 @@ getCallState\(callback: AsyncCallback<CallState\>\): void
...
@@ -226,7 +226,7 @@ getCallState\(callback: AsyncCallback<CallState\>\): void
**示例:**
**示例:**
```
```
js
call
.
getCallState
((
err
,
data
)
=>
{
call
.
getCallState
((
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -249,7 +249,7 @@ getCallState\(\): Promise<CallState\>
...
@@ -249,7 +249,7 @@ getCallState\(\): Promise<CallState\>
**示例:**
**示例:**
```
```
js
let
promise
=
call
.
getCallState
();
let
promise
=
call
.
getCallState
();
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`getCallState success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`getCallState success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -272,7 +272,7 @@ hasVoiceCapability(): boolean
...
@@ -272,7 +272,7 @@ hasVoiceCapability(): boolean
| ------- | ------------------------------------------------------------ |
| ------- | ------------------------------------------------------------ |
| boolean | - true:设备具备语音通话能力
<br/>
- false:设备不具备语音通话能力 |
| boolean | - true:设备具备语音通话能力
<br/>
- false:设备不具备语音通话能力 |
```
```
js
let
result
=
call
.
hasVoiceCapability
();
let
result
=
call
.
hasVoiceCapability
();
console
.
log
(
`hasVoiceCapability:
${
JSON
.
stringify
(
result
)}
`
);
console
.
log
(
`hasVoiceCapability:
${
JSON
.
stringify
(
result
)}
`
);
```
```
...
@@ -294,7 +294,7 @@ isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback<boolean\>\)
...
@@ -294,7 +294,7 @@ isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback<boolean\>\)
**示例:**
**示例:**
```
```
js
call
.
isEmergencyPhoneNumber
(
"
138xxxxxxxx
"
,
(
err
,
data
)
=>
{
call
.
isEmergencyPhoneNumber
(
"
138xxxxxxxx
"
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -319,7 +319,7 @@ isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, ca
...
@@ -319,7 +319,7 @@ isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, ca
**示例:**
**示例:**
```
```
js
call
.
isEmergencyPhoneNumber
(
"
112
"
,
{
slotId
:
1
},
(
err
,
value
)
=>
{
call
.
isEmergencyPhoneNumber
(
"
112
"
,
{
slotId
:
1
},
(
err
,
value
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -349,7 +349,7 @@ isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\):
...
@@ -349,7 +349,7 @@ isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\):
**示例:**
**示例:**
```
```
js
let
promise
=
call
.
isEmergencyPhoneNumber
(
"
138xxxxxxxx
"
,
{
slotId
:
1
});
let
promise
=
call
.
isEmergencyPhoneNumber
(
"
138xxxxxxxx
"
,
{
slotId
:
1
});
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`isEmergencyPhoneNumber success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`isEmergencyPhoneNumber success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -375,7 +375,7 @@ formatPhoneNumber\(phoneNumber: string, callback: AsyncCallback<string\>\): void
...
@@ -375,7 +375,7 @@ formatPhoneNumber\(phoneNumber: string, callback: AsyncCallback<string\>\): void
**示例:**
**示例:**
```
```
js
call
.
formatPhoneNumber
(
"
138xxxxxxxx
"
,
(
err
,
data
)
=>
{
call
.
formatPhoneNumber
(
"
138xxxxxxxx
"
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -400,7 +400,7 @@ formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback:
...
@@ -400,7 +400,7 @@ formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback:
**示例:**
**示例:**
```
```
js
call
.
formatPhoneNumber
(
"
138xxxxxxxx
"
,{
call
.
formatPhoneNumber
(
"
138xxxxxxxx
"
,{
countryCode
:
"
CN
"
countryCode
:
"
CN
"
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -432,7 +432,7 @@ formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise
...
@@ -432,7 +432,7 @@ formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise
**示例:**
**示例:**
```
```
js
let
promise
=
call
.
formatPhoneNumber
(
"
138xxxxxxxx
"
,
{
let
promise
=
call
.
formatPhoneNumber
(
"
138xxxxxxxx
"
,
{
countryCode
:
"
CN
"
countryCode
:
"
CN
"
});
});
...
@@ -465,7 +465,7 @@ formatPhoneNumberToE164\(phoneNumber: string, countryCode: string, callback: Asy
...
@@ -465,7 +465,7 @@ formatPhoneNumberToE164\(phoneNumber: string, countryCode: string, callback: Asy
**示例:**
**示例:**
```
```
js
call
.
formatPhoneNumberToE164
(
"
138xxxxxxxx
"
,{
call
.
formatPhoneNumberToE164
(
"
138xxxxxxxx
"
,{
countryCode
:
"
CN
"
countryCode
:
"
CN
"
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -501,7 +501,7 @@ formatPhoneNumberToE164\(phoneNumber: string, countryCode: string\): Promise<str
...
@@ -501,7 +501,7 @@ formatPhoneNumberToE164\(phoneNumber: string, countryCode: string\): Promise<str
**示例:**
**示例:**
```
```
js
let
promise
=
call
.
formatPhoneNumberToE164
(
"
138xxxxxxxx
"
,
{
let
promise
=
call
.
formatPhoneNumberToE164
(
"
138xxxxxxxx
"
,
{
countryCode
:
"
CN
"
countryCode
:
"
CN
"
});
});
...
...
zh-cn/application-dev/reference/apis/js-apis-contact.md
浏览文件 @
6acf3db4
...
@@ -29,7 +29,7 @@ addContact(contact:Contact, callback:AsyncCallback<number>): void
...
@@ -29,7 +29,7 @@ addContact(contact:Contact, callback:AsyncCallback<number>): void
**示例:**
**示例:**
```
```
js
contact
.
addContact
({
contact
.
addContact
({
fullName
:
{
fullName
:
'
xxx
'
},
fullName
:
{
fullName
:
'
xxx
'
},
phoneNumbers
:
[{
phoneNumber
:
'
138xxxxxxxx
'
}]
phoneNumbers
:
[{
phoneNumber
:
'
138xxxxxxxx
'
}]
...
@@ -65,7 +65,7 @@ addContact(contact: Contact): Promise<number>
...
@@ -65,7 +65,7 @@ addContact(contact: Contact): Promise<number>
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
addContact
({
let
promise
=
contact
.
addContact
({
name
:
{
fullName
:
'
xxx
'
},
name
:
{
fullName
:
'
xxx
'
},
phoneNumbers
:
[{
phoneNumber
:
'
138xxxxxxxx
'
}]
phoneNumbers
:
[{
phoneNumber
:
'
138xxxxxxxx
'
}]
...
@@ -96,7 +96,7 @@ deleteContact(key: string, callback: AsyncCallback<void>): void
...
@@ -96,7 +96,7 @@ deleteContact(key: string, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
```
js
contact
.
deleteContact
(
'
xxx
'
,
(
err
)
=>
{
contact
.
deleteContact
(
'
xxx
'
,
(
err
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
`deleteContact callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`deleteContact callback: err->
${
JSON
.
stringify
(
err
)}
`
);
...
@@ -129,7 +129,7 @@ deleteContact(key: string): Promise<void>
...
@@ -129,7 +129,7 @@ deleteContact(key: string): Promise<void>
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
deleteContact
(
'
xxx
'
);
let
promise
=
contact
.
deleteContact
(
'
xxx
'
);
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
console
.
log
(
`deleteContact success`
);
console
.
log
(
`deleteContact success`
);
...
@@ -157,7 +157,7 @@ updateContact(contact: Contact, callback: AsyncCallback<void>): void
...
@@ -157,7 +157,7 @@ updateContact(contact: Contact, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
```
js
contact
.
updateContact
({
contact
.
updateContact
({
name
:
{
fullName
:
'
xxx
'
},
name
:
{
fullName
:
'
xxx
'
},
phoneNumbers
:
[{
phoneNumber
:
'
138xxxxxxxx
'
}]
phoneNumbers
:
[{
phoneNumber
:
'
138xxxxxxxx
'
}]
...
@@ -190,7 +190,7 @@ updateContact(contact: Contact, attrs: ContactAttributes, callback: AsyncCallbac
...
@@ -190,7 +190,7 @@ updateContact(contact: Contact, attrs: ContactAttributes, callback: AsyncCallbac
**示例:**
**示例:**
```
```
js
contact
.
updateContact
({
contact
.
updateContact
({
fullName
:
{
fullName
:
'
xxx
'
},
fullName
:
{
fullName
:
'
xxx
'
},
phoneNumbers
:
[{
phoneNumber
:
'
138xxxxxxxx
'
}]
phoneNumbers
:
[{
phoneNumber
:
'
138xxxxxxxx
'
}]
...
@@ -229,7 +229,7 @@ updateContact(contact: Contact, attrs?: ContactAttributes): Promise<void>
...
@@ -229,7 +229,7 @@ updateContact(contact: Contact, attrs?: ContactAttributes): Promise<void>
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
updateContact
({
let
promise
=
contact
.
updateContact
({
fullName
:
{
fullName
:
'
xxx
'
},
fullName
:
{
fullName
:
'
xxx
'
},
phoneNumbers
:
[{
phoneNumber
:
'
138xxxxxxxx
'
}]
phoneNumbers
:
[{
phoneNumber
:
'
138xxxxxxxx
'
}]
...
@@ -262,7 +262,7 @@ isLocalContact(id: number, callback: AsyncCallback<boolean>): void
...
@@ -262,7 +262,7 @@ isLocalContact(id: number, callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
```
js
contact
.
isLocalContact
(
/*id*/
1
,
(
err
,
data
)
=>
{
contact
.
isLocalContact
(
/*id*/
1
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
`isLocalContact callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`isLocalContact callback: err->
${
JSON
.
stringify
(
err
)}
`
);
...
@@ -295,7 +295,7 @@ isLocalContact(id: number): Promise<boolean>
...
@@ -295,7 +295,7 @@ isLocalContact(id: number): Promise<boolean>
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
isLocalContact
(
/*id*/
1
);
let
promise
=
contact
.
isLocalContact
(
/*id*/
1
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
log
(
`isLocalContact success: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`isLocalContact success: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -323,7 +323,7 @@ isMyCard(id: number, callback: AsyncCallback<boolean>): void
...
@@ -323,7 +323,7 @@ isMyCard(id: number, callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
```
js
contact
.
isMyCard
(
/*id*/
1
,
(
err
,
data
)
=>
{
contact
.
isMyCard
(
/*id*/
1
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
`isMyCard callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`isMyCard callback: err->
${
JSON
.
stringify
(
err
)}
`
);
...
@@ -356,7 +356,7 @@ isMyCard(id: number): Promise<boolean>
...
@@ -356,7 +356,7 @@ isMyCard(id: number): Promise<boolean>
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
isMyCard
(
/*id*/
1
);
let
promise
=
contact
.
isMyCard
(
/*id*/
1
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
log
(
`isMyCard success: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`isMyCard success: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -383,7 +383,7 @@ queryMyCard(callback: AsyncCallback<Contact>): void
...
@@ -383,7 +383,7 @@ queryMyCard(callback: AsyncCallback<Contact>): void
**示例:**
**示例:**
```
```
js
contact
.
queryMyCard
((
err
,
data
)
=>
{
contact
.
queryMyCard
((
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
`queryMyCard callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`queryMyCard callback: err->
${
JSON
.
stringify
(
err
)}
`
);
...
@@ -412,7 +412,7 @@ queryMyCard(attrs: ContactAttributes, callback: AsyncCallback<Contact>): v
...
@@ -412,7 +412,7 @@ queryMyCard(attrs: ContactAttributes, callback: AsyncCallback<Contact>): v
**示例:**
**示例:**
```
```
js
contact
.
queryMyCard
({
contact
.
queryMyCard
({
attributes
:[
'
ATTR_EMAIL
'
,
'
ATTR_NAME
'
]
attributes
:[
'
ATTR_EMAIL
'
,
'
ATTR_NAME
'
]
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -447,7 +447,7 @@ queryMyCard(attrs?: ContactAttributes): Promise<Contact>
...
@@ -447,7 +447,7 @@ queryMyCard(attrs?: ContactAttributes): Promise<Contact>
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
queryMyCard
({
let
promise
=
contact
.
queryMyCard
({
attributes
:[
'
ATTR_EMAIL
'
,
'
ATTR_NAME
'
]
attributes
:[
'
ATTR_EMAIL
'
,
'
ATTR_NAME
'
]
});
});
...
@@ -478,7 +478,7 @@ selectContact(callback: AsyncCallback<Array<Contact>>): void
...
@@ -478,7 +478,7 @@ selectContact(callback: AsyncCallback<Array<Contact>>): void
**示例:**
**示例:**
```
```
js
contact
.
selectContact
((
err
,
data
)
=>
{
contact
.
selectContact
((
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
`selectContact callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`selectContact callback: err->
${
JSON
.
stringify
(
err
)}
`
);
...
@@ -508,7 +508,7 @@ selectContact(): Promise<Array<Contact>>
...
@@ -508,7 +508,7 @@ selectContact(): Promise<Array<Contact>>
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
selectContact
();
let
promise
=
contact
.
selectContact
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
log
(
`selectContact success: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`selectContact success: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -536,7 +536,7 @@ queryContact(key: string, callback: AsyncCallback<Contact>): void
...
@@ -536,7 +536,7 @@ queryContact(key: string, callback: AsyncCallback<Contact>): void
**示例:**
**示例:**
```
```
js
contact
.
queryContact
(
'
xxx
'
,
(
err
,
data
)
=>
{
contact
.
queryContact
(
'
xxx
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
`queryContact callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`queryContact callback: err->
${
JSON
.
stringify
(
err
)}
`
);
...
@@ -566,7 +566,7 @@ queryContact(key: string, holder: Holder, callback: AsyncCallback<Contact>
...
@@ -566,7 +566,7 @@ queryContact(key: string, holder: Holder, callback: AsyncCallback<Contact>
**示例:**
**示例:**
```
```
js
contact
.
queryContact
(
'
xxx
'
,
{
contact
.
queryContact
(
'
xxx
'
,
{
holderId
:
0
holderId
:
0
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -598,7 +598,7 @@ queryContact(key: string, attrs: ContactAttributes, callback: AsyncCallback<
...
@@ -598,7 +598,7 @@ queryContact(key: string, attrs: ContactAttributes, callback: AsyncCallback<
**示例:**
**示例:**
```
```
js
contact
.
queryContact
(
'
xxx
'
,
{
contact
.
queryContact
(
'
xxx
'
,
{
attributes
:
[
"
ATTR_EMAIL
"
,
"
ATTR_NAME
"
]
attributes
:
[
"
ATTR_EMAIL
"
,
"
ATTR_NAME
"
]
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -631,7 +631,7 @@ queryContact(key: string, holder: Holder, attrs: ContactAttributes, callback: As
...
@@ -631,7 +631,7 @@ queryContact(key: string, holder: Holder, attrs: ContactAttributes, callback: As
**示例:**
**示例:**
```
```
js
contact
.
queryContact
(
'
xxx
'
,
{
contact
.
queryContact
(
'
xxx
'
,
{
holderId
:
0
holderId
:
0
},
{
},
{
...
@@ -670,7 +670,7 @@ queryContact(key: string, holder?: Holder, attrs?: ContactAttributes): Promise&l
...
@@ -670,7 +670,7 @@ queryContact(key: string, holder?: Holder, attrs?: ContactAttributes): Promise&l
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
queryContact
(
'
xxx
'
,
{
let
promise
=
contact
.
queryContact
(
'
xxx
'
,
{
holderId
:
0
holderId
:
0
},
{
},
{
...
@@ -701,7 +701,7 @@ queryContacts(callback: AsyncCallback<Array<Contact>>): void
...
@@ -701,7 +701,7 @@ queryContacts(callback: AsyncCallback<Array<Contact>>): void
**示例:**
**示例:**
```
```
js
contact
.
queryContacts
((
err
,
data
)
=>
{
contact
.
queryContacts
((
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
`queryContacts callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`queryContacts callback: err->
${
JSON
.
stringify
(
err
)}
`
);
...
@@ -730,7 +730,7 @@ queryContacts(holder: Holder, callback: AsyncCallback<Array<Contact>>
...
@@ -730,7 +730,7 @@ queryContacts(holder: Holder, callback: AsyncCallback<Array<Contact>>
**示例:**
**示例:**
```
```
js
contact
.
queryContacts
({
contact
.
queryContacts
({
holderId
:
0
holderId
:
0
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -761,7 +761,7 @@ queryContacts(attrs: ContactAttributes, callback: AsyncCallback<Array<Cont
...
@@ -761,7 +761,7 @@ queryContacts(attrs: ContactAttributes, callback: AsyncCallback<Array<Cont
**示例:**
**示例:**
```
```
js
contact
.
queryContacts
({
contact
.
queryContacts
({
attributes
:
[
"
ATTR_EMAIL
"
,
"
ATTR_NAME
"
]
attributes
:
[
"
ATTR_EMAIL
"
,
"
ATTR_NAME
"
]
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -793,7 +793,7 @@ queryContacts(holder: Holder, attrs: ContactAttributes, callback: AsyncCallback&
...
@@ -793,7 +793,7 @@ queryContacts(holder: Holder, attrs: ContactAttributes, callback: AsyncCallback&
**示例:**
**示例:**
```
```
js
contact
.
queryContacts
({
contact
.
queryContacts
({
holderId
:
0
holderId
:
0
},
{
},
{
...
@@ -831,7 +831,7 @@ queryContacts(holder?: Holder, attrs?: ContactAttributes): Promise<Array<C
...
@@ -831,7 +831,7 @@ queryContacts(holder?: Holder, attrs?: ContactAttributes): Promise<Array<C
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
queryContacts
({
let
promise
=
contact
.
queryContacts
({
holderId
:
0
holderId
:
0
},
{
},
{
...
@@ -863,7 +863,7 @@ queryContactsByPhoneNumber(phoneNumber: string, callback: AsyncCallback<Array
...
@@ -863,7 +863,7 @@ queryContactsByPhoneNumber(phoneNumber: string, callback: AsyncCallback<Array
**示例:**
**示例:**
```
```
js
contact
.
queryContactsByPhoneNumber
(
'
138xxxxxxxx
'
,
(
err
,
data
)
=>
{
contact
.
queryContactsByPhoneNumber
(
'
138xxxxxxxx
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
`queryContactsByPhoneNumber callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`queryContactsByPhoneNumber callback: err->
${
JSON
.
stringify
(
err
)}
`
);
...
@@ -893,7 +893,7 @@ queryContactsByPhoneNumber(phoneNumber: string, holder: Holder, callback: AsyncC
...
@@ -893,7 +893,7 @@ queryContactsByPhoneNumber(phoneNumber: string, holder: Holder, callback: AsyncC
**示例:**
**示例:**
```
```
js
contact
.
queryContactsByPhoneNumber
(
'
138xxxxxxxx
'
,
{
contact
.
queryContactsByPhoneNumber
(
'
138xxxxxxxx
'
,
{
holderId
:
0
holderId
:
0
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -925,7 +925,7 @@ queryContactsByPhoneNumber(phoneNumber: string, attrs: ContactAttributes, callba
...
@@ -925,7 +925,7 @@ queryContactsByPhoneNumber(phoneNumber: string, attrs: ContactAttributes, callba
**示例:**
**示例:**
```
```
js
contact
.
queryContactsByPhoneNumber
(
'
138xxxxxxxx
'
,
{
contact
.
queryContactsByPhoneNumber
(
'
138xxxxxxxx
'
,
{
attributes
:
[
"
ATTR_EMAIL
"
,
"
ATTR_NAME
"
]
attributes
:
[
"
ATTR_EMAIL
"
,
"
ATTR_NAME
"
]
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -958,7 +958,7 @@ queryContactsByPhoneNumber(phoneNumber: string, holder: Holder, attrs: ContactAt
...
@@ -958,7 +958,7 @@ queryContactsByPhoneNumber(phoneNumber: string, holder: Holder, attrs: ContactAt
**示例:**
**示例:**
```
```
js
contact
.
queryContactsByPhoneNumber
(
'
138xxxxxxxx
'
,
{
contact
.
queryContactsByPhoneNumber
(
'
138xxxxxxxx
'
,
{
holderId
:
0
holderId
:
0
},
{
},
{
...
@@ -997,7 +997,7 @@ queryContactsByPhoneNumber(phoneNumber: string, holder?: Holder, attrs?: Contact
...
@@ -997,7 +997,7 @@ queryContactsByPhoneNumber(phoneNumber: string, holder?: Holder, attrs?: Contact
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
queryContactsByPhoneNumber
(
'
138xxxxxxxx
'
,
{
let
promise
=
contact
.
queryContactsByPhoneNumber
(
'
138xxxxxxxx
'
,
{
holderId
:
0
holderId
:
0
},
{
},
{
...
@@ -1029,7 +1029,7 @@ queryContactsByEmail(email: string, callback: AsyncCallback<Array<Contact&
...
@@ -1029,7 +1029,7 @@ queryContactsByEmail(email: string, callback: AsyncCallback<Array<Contact&
**示例:**
**示例:**
```
```
js
contact
.
queryContactsByEmail
(
'
xxx@email.com
'
,
(
err
,
data
)
=>
{
contact
.
queryContactsByEmail
(
'
xxx@email.com
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
`queryContactsByEmail callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`queryContactsByEmail callback: err->
${
JSON
.
stringify
(
err
)}
`
);
...
@@ -1059,7 +1059,7 @@ queryContactsByEmail(email: string, holder: Holder, callback: AsyncCallback<A
...
@@ -1059,7 +1059,7 @@ queryContactsByEmail(email: string, holder: Holder, callback: AsyncCallback<A
**示例:**
**示例:**
```
```
js
contact
.
queryContactsByEmail
(
'
xxx@email.com
'
,
{
contact
.
queryContactsByEmail
(
'
xxx@email.com
'
,
{
holderId
:
0
holderId
:
0
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -1091,7 +1091,7 @@ queryContactsByEmail(email: string, attrs: ContactAttributes, callback: AsyncCal
...
@@ -1091,7 +1091,7 @@ queryContactsByEmail(email: string, attrs: ContactAttributes, callback: AsyncCal
**示例:**
**示例:**
```
```
js
contact
.
queryContactsByEmail
(
'
xxx@email.com
'
,
{
contact
.
queryContactsByEmail
(
'
xxx@email.com
'
,
{
attributes
:
[
"
ATTR_EMAIL
"
,
"
ATTR_NAME
"
]
attributes
:
[
"
ATTR_EMAIL
"
,
"
ATTR_NAME
"
]
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -1124,7 +1124,7 @@ queryContactsByEmail(email: string, holder: Holder, attrs: ContactAttributes, ca
...
@@ -1124,7 +1124,7 @@ queryContactsByEmail(email: string, holder: Holder, attrs: ContactAttributes, ca
**示例:**
**示例:**
```
```
js
contact
.
queryContactsByEmail
(
'
xxx@email.com
'
,
{
contact
.
queryContactsByEmail
(
'
xxx@email.com
'
,
{
holderId
:
0
holderId
:
0
},
{
},
{
...
@@ -1163,7 +1163,7 @@ queryContactsByEmail(email: string, holder?: Holder, attrs?: ContactAttributes):
...
@@ -1163,7 +1163,7 @@ queryContactsByEmail(email: string, holder?: Holder, attrs?: ContactAttributes):
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
queryContactsByEmail
(
'
xxx@email.com
'
,
{
let
promise
=
contact
.
queryContactsByEmail
(
'
xxx@email.com
'
,
{
holderId
:
0
holderId
:
0
},
{
},
{
...
@@ -1194,7 +1194,7 @@ queryGroups(callback: AsyncCallback<Array<Group>>): void
...
@@ -1194,7 +1194,7 @@ queryGroups(callback: AsyncCallback<Array<Group>>): void
**示例:**
**示例:**
```
```
js
contact
.
queryGroups
((
err
,
data
)
=>
{
contact
.
queryGroups
((
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
`queryGroups callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`queryGroups callback: err->
${
JSON
.
stringify
(
err
)}
`
);
...
@@ -1223,7 +1223,7 @@ queryGroups(holder: Holder, callback: AsyncCallback<Array<Group>>):
...
@@ -1223,7 +1223,7 @@ queryGroups(holder: Holder, callback: AsyncCallback<Array<Group>>):
**示例:**
**示例:**
```
```
js
contact
.
queryGroups
({
contact
.
queryGroups
({
holderId
:
0
holderId
:
0
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -1258,7 +1258,7 @@ queryGroups(holder?: Holder): Promise<Array<Group>>
...
@@ -1258,7 +1258,7 @@ queryGroups(holder?: Holder): Promise<Array<Group>>
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
queryGroups
({
let
promise
=
contact
.
queryGroups
({
holderId
:
0
holderId
:
0
});
});
...
@@ -1287,7 +1287,7 @@ queryHolders(callback: AsyncCallback<Array<Holder>>): void
...
@@ -1287,7 +1287,7 @@ queryHolders(callback: AsyncCallback<Array<Holder>>): void
**示例:**
**示例:**
```
```
js
contact
.
queryHolders
((
err
,
data
)
=>
{
contact
.
queryHolders
((
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
`queryHolders callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`queryHolders callback: err->
${
JSON
.
stringify
(
err
)}
`
);
...
@@ -1315,7 +1315,7 @@ queryHolders(): Promise<Array<Holder>>
...
@@ -1315,7 +1315,7 @@ queryHolders(): Promise<Array<Holder>>
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
queryHolders
();
let
promise
=
contact
.
queryHolders
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
log
(
`queryHolders success: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`queryHolders success: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -1343,7 +1343,7 @@ queryKey(id: number, callback: AsyncCallback<string>): void
...
@@ -1343,7 +1343,7 @@ queryKey(id: number, callback: AsyncCallback<string>): void
**示例:**
**示例:**
```
```
js
contact
.
queryKey
(
/*id*/
1
,
(
err
,
data
)
=>
{
contact
.
queryKey
(
/*id*/
1
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
`queryKey callback: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`queryKey callback: err->
${
JSON
.
stringify
(
err
)}
`
);
...
@@ -1373,7 +1373,7 @@ queryKey(id: number, holder: Holder, callback: AsyncCallback<string>): voi
...
@@ -1373,7 +1373,7 @@ queryKey(id: number, holder: Holder, callback: AsyncCallback<string>): voi
**示例:**
**示例:**
```
```
js
contact
.
queryKey
(
id
,
{
contact
.
queryKey
(
id
,
{
holderId
:
1
holderId
:
1
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
...
@@ -1409,7 +1409,7 @@ queryKey(id: number, holder?: Holder): Promise<string>
...
@@ -1409,7 +1409,7 @@ queryKey(id: number, holder?: Holder): Promise<string>
**示例:**
**示例:**
```
```
js
let
promise
=
contact
.
queryKey
(
id
,
{
let
promise
=
contact
.
queryKey
(
id
,
{
holderId
:
0
holderId
:
0
});
});
...
@@ -1462,7 +1462,7 @@ queryKey(id: number, holder?: Holder): Promise<string>
...
@@ -1462,7 +1462,7 @@ queryKey(id: number, holder?: Holder): Promise<string>
使用JSON格式创建联系人数据:
使用JSON格式创建联系人数据:
```
```
json
let
myContact
=
{
let
myContact
=
{
phoneNumbers:
[{
phoneNumbers:
[{
phoneNumber:
"138xxxxxxxx"
phoneNumber:
"138xxxxxxxx"
...
@@ -1480,7 +1480,7 @@ let myContact = {
...
@@ -1480,7 +1480,7 @@ let myContact = {
或使用new一个Contact对象的方式创建数据:
或使用new一个Contact对象的方式创建数据:
```
```
js
let
myContact
=
new
contact
.
Contact
();
let
myContact
=
new
contact
.
Contact
();
let
name
=
new
contact
.
Name
();
let
name
=
new
contact
.
Name
();
name
.
fullName
=
"
fullName
"
;
name
.
fullName
=
"
fullName
"
;
...
@@ -1508,7 +1508,7 @@ myContact.phoneNumbers = [phoneNumber];
...
@@ -1508,7 +1508,7 @@ myContact.phoneNumbers = [phoneNumber];
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
contactAttributes
=
{
let
contactAttributes
=
{
attributes:
[
attributes:
[
contact.Attribute.ATTR_EMAIL
,
contact.Attribute.ATTR_EMAIL
,
...
@@ -1521,7 +1521,7 @@ let contactAttributes = {
...
@@ -1521,7 +1521,7 @@ let contactAttributes = {
或使用new一个ContactAttributes对象的方式创建数据:
或使用new一个ContactAttributes对象的方式创建数据:
```
```
js
let
contactAttributes
=
new
contact
.
ContactAttributes
();
let
contactAttributes
=
new
contact
.
ContactAttributes
();
contactAttributes
.
attributes
=
[
"
ATTR_EMAIL
"
];
contactAttributes
.
attributes
=
[
"
ATTR_EMAIL
"
];
```
```
...
@@ -1555,7 +1555,7 @@ contactAttributes.attributes = ["ATTR_EMAIL"];
...
@@ -1555,7 +1555,7 @@ contactAttributes.attributes = ["ATTR_EMAIL"];
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
attributes
=
[
contact.Attribute.ATTR_EMAIL
,
contact.Attribute.ATTR_NAME
,
contact.Attribute.ATTR_PHONE
]
;
let
attributes
=
[
contact.Attribute.ATTR_EMAIL
,
contact.Attribute.ATTR_NAME
,
contact.Attribute.ATTR_PHONE
]
;
```
```
...
@@ -1591,7 +1591,7 @@ let attributes = [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME, con
...
@@ -1591,7 +1591,7 @@ let attributes = [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME, con
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
email
=
{
let
email
=
{
email:
"xxx@email.com"
,
email:
"xxx@email.com"
,
displayName:
"displayName"
displayName:
"displayName"
...
@@ -1601,7 +1601,7 @@ let email = {
...
@@ -1601,7 +1601,7 @@ let email = {
或使用new一个Email对象的方式创建数据:
或使用new一个Email对象的方式创建数据:
```
```
js
let
email
=
new
contact
.
Email
();
let
email
=
new
contact
.
Email
();
email
.
email
=
"
xxx@email.com
"
;
email
.
email
=
"
xxx@email.com
"
;
```
```
...
@@ -1624,7 +1624,7 @@ email.email = "xxx@email.com";
...
@@ -1624,7 +1624,7 @@ email.email = "xxx@email.com";
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
holder
=
{
let
holder
=
{
holderId:
0
holderId:
0
}
;
}
;
...
@@ -1632,7 +1632,7 @@ let holder = {
...
@@ -1632,7 +1632,7 @@ let holder = {
或使用new一个Holder对象的方式创建数据:
或使用new一个Holder对象的方式创建数据:
```
```
js
let
holder
=
new
contact
.
Holder
();
let
holder
=
new
contact
.
Holder
();
holder
.
holderId
=
0
;
holder
.
holderId
=
0
;
```
```
...
@@ -1668,7 +1668,7 @@ holder.holderId = 0;
...
@@ -1668,7 +1668,7 @@ holder.holderId = 0;
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
event
=
{
let
event
=
{
eventDate:
"xxxxxx"
eventDate:
"xxxxxx"
}
;
}
;
...
@@ -1676,7 +1676,7 @@ let event = {
...
@@ -1676,7 +1676,7 @@ let event = {
或使用new一个Event对象的方式创建数据:
或使用new一个Event对象的方式创建数据:
```
```
js
let
event
=
new
contact
.
Event
();
let
event
=
new
contact
.
Event
();
event
.
eventDate
=
"
xxxxxx
"
;
event
.
eventDate
=
"
xxxxxx
"
;
```
```
...
@@ -1698,7 +1698,7 @@ event.eventDate = "xxxxxx";
...
@@ -1698,7 +1698,7 @@ event.eventDate = "xxxxxx";
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
group
=
{
let
group
=
{
groupId:
1
,
groupId:
1
,
title:
"title"
title:
"title"
...
@@ -1707,7 +1707,7 @@ let group = {
...
@@ -1707,7 +1707,7 @@ let group = {
或使用new一个Group对象的方式创建数据:
或使用new一个Group对象的方式创建数据:
```
```
js
let
group
=
new
contact
.
Group
();
let
group
=
new
contact
.
Group
();
group
.
title
=
"
title
"
;
group
.
title
=
"
title
"
;
```
```
...
@@ -1747,7 +1747,7 @@ group.title = "title";
...
@@ -1747,7 +1747,7 @@ group.title = "title";
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
imAddress
=
{
let
imAddress
=
{
imAddress:
"imAddress"
,
imAddress:
"imAddress"
,
labelName:
"labelName"
labelName:
"labelName"
...
@@ -1757,7 +1757,7 @@ let imAddress = {
...
@@ -1757,7 +1757,7 @@ let imAddress = {
或使用new一个ImAddress对象的方式创建数据:
或使用new一个ImAddress对象的方式创建数据:
```
```
js
let
imAddress
=
new
contact
.
ImAddress
();
let
imAddress
=
new
contact
.
ImAddress
();
imAddress
.
imAddress
=
"
imAddress
"
;
imAddress
.
imAddress
=
"
imAddress
"
;
```
```
...
@@ -1786,7 +1786,7 @@ imAddress.imAddress = "imAddress";
...
@@ -1786,7 +1786,7 @@ imAddress.imAddress = "imAddress";
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
name
=
{
let
name
=
{
familyName:
"familyName"
,
familyName:
"familyName"
,
fullName:
"fullName"
fullName:
"fullName"
...
@@ -1795,7 +1795,7 @@ let name = {
...
@@ -1795,7 +1795,7 @@ let name = {
或使用new一个name对象的方式创建数据:
或使用new一个name对象的方式创建数据:
```
```
js
let
name
=
new
contact
.
Name
();
let
name
=
new
contact
.
Name
();
name
.
familyName
=
"
familyName
"
;
name
.
familyName
=
"
familyName
"
;
name
.
fullName
=
"
fullName
"
;
name
.
fullName
=
"
fullName
"
;
...
@@ -1817,7 +1817,7 @@ name.fullName = "fullName";
...
@@ -1817,7 +1817,7 @@ name.fullName = "fullName";
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
nickName
=
{
let
nickName
=
{
nickName:
"nickName"
nickName:
"nickName"
}
;
}
;
...
@@ -1825,7 +1825,7 @@ let nickName = {
...
@@ -1825,7 +1825,7 @@ let nickName = {
或使用new一个NickName对象的方式创建数据:
或使用new一个NickName对象的方式创建数据:
```
```
js
let
nickName
=
new
contact
.
NickName
();
let
nickName
=
new
contact
.
NickName
();
nickName
.
nickName
=
"
nickName
"
;
nickName
.
nickName
=
"
nickName
"
;
```
```
...
@@ -1846,7 +1846,7 @@ nickName.nickName = "nickName";
...
@@ -1846,7 +1846,7 @@ nickName.nickName = "nickName";
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
note
=
{
let
note
=
{
noteContent:
"noteContent"
noteContent:
"noteContent"
}
;
}
;
...
@@ -1854,7 +1854,7 @@ let note = {
...
@@ -1854,7 +1854,7 @@ let note = {
或使用new一个Note对象的方式创建数据:
或使用new一个Note对象的方式创建数据:
```
```
js
let
note
=
new
contact
.
Note
();
let
note
=
new
contact
.
Note
();
note
.
noteContent
=
"
noteContent
"
;
note
.
noteContent
=
"
noteContent
"
;
```
```
...
@@ -1876,7 +1876,7 @@ note.noteContent = "noteContent";
...
@@ -1876,7 +1876,7 @@ note.noteContent = "noteContent";
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
organization
=
{
let
organization
=
{
name:
"name"
,
name:
"name"
,
title:
"title"
title:
"title"
...
@@ -1885,7 +1885,7 @@ let organization = {
...
@@ -1885,7 +1885,7 @@ let organization = {
或使用new一个Organization对象的方式创建数据:
或使用new一个Organization对象的方式创建数据:
```
```
js
let
organization
=
new
contact
.
Organization
();
let
organization
=
new
contact
.
Organization
();
organization
.
name
=
"
name
"
;
organization
.
name
=
"
name
"
;
organization
.
title
=
"
title
"
;
organization
.
title
=
"
title
"
;
...
@@ -1939,7 +1939,7 @@ organization.title = "title";
...
@@ -1939,7 +1939,7 @@ organization.title = "title";
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
phoneNumber
=
{
let
phoneNumber
=
{
phoneNumber:
"138xxxxxxxx"
,
phoneNumber:
"138xxxxxxxx"
,
labelId:
contact.PhoneNumber.NUM_HOME
labelId:
contact.PhoneNumber.NUM_HOME
...
@@ -1948,7 +1948,7 @@ let phoneNumber = {
...
@@ -1948,7 +1948,7 @@ let phoneNumber = {
或使用new一个PhoneNumber对象的方式创建数据:
或使用new一个PhoneNumber对象的方式创建数据:
```
```
js
let
phoneNumber
=
new
contact
.
PhoneNumber
();
let
phoneNumber
=
new
contact
.
PhoneNumber
();
phoneNumber
.
phoneNumber
=
"
138xxxxxxxx
"
;
phoneNumber
.
phoneNumber
=
"
138xxxxxxxx
"
;
```
```
...
@@ -1969,7 +1969,7 @@ phoneNumber.phoneNumber = "138xxxxxxxx";
...
@@ -1969,7 +1969,7 @@ phoneNumber.phoneNumber = "138xxxxxxxx";
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
portrait
=
{
let
portrait
=
{
uri:
"uri"
uri:
"uri"
}
;
}
;
...
@@ -1977,7 +1977,7 @@ let portrait = {
...
@@ -1977,7 +1977,7 @@ let portrait = {
或使用new一个Portrait对象的方式创建数据:
或使用new一个Portrait对象的方式创建数据:
```
```
js
let
portrait
=
new
contact
.
Portrait
();
let
portrait
=
new
contact
.
Portrait
();
portrait
.
uri
=
"
uri
"
;
portrait
.
uri
=
"
uri
"
;
```
```
...
@@ -2020,7 +2020,7 @@ portrait.uri = "uri";
...
@@ -2020,7 +2020,7 @@ portrait.uri = "uri";
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
postalAddress
=
{
let
postalAddress
=
{
city:
"city"
city:
"city"
}
;
}
;
...
@@ -2028,7 +2028,7 @@ let postalAddress = {
...
@@ -2028,7 +2028,7 @@ let postalAddress = {
或使用new一个PostalAddress对象的方式创建数据:
或使用new一个PostalAddress对象的方式创建数据:
```
```
js
let
postalAddress
=
new
contact
.
PostalAddress
();
let
postalAddress
=
new
contact
.
PostalAddress
();
postalAddress
.
city
=
"
city
"
;
postalAddress
.
city
=
"
city
"
;
```
```
...
@@ -2075,7 +2075,7 @@ postalAddress.city = "city";
...
@@ -2075,7 +2075,7 @@ postalAddress.city = "city";
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
relation
=
{
let
relation
=
{
relationName:
"relationName"
,
relationName:
"relationName"
,
labelId:
contact.Relation.RELATION_ASSISTANT
labelId:
contact.Relation.RELATION_ASSISTANT
...
@@ -2084,7 +2084,7 @@ let relation = {
...
@@ -2084,7 +2084,7 @@ let relation = {
或使用new一个Relation对象的方式创建数据:
或使用new一个Relation对象的方式创建数据:
```
```
js
let
relation
=
new
contact
.
Relation
();
let
relation
=
new
contact
.
Relation
();
relation
.
relationName
=
"
relationName
"
;
relation
.
relationName
=
"
relationName
"
;
relation
.
labelId
=
contact
.
Relation
.
RELATION_ASSISTANT
;
relation
.
labelId
=
contact
.
Relation
.
RELATION_ASSISTANT
;
...
@@ -2121,7 +2121,7 @@ relation.labelId = contact.Relation.RELATION_ASSISTANT;
...
@@ -2121,7 +2121,7 @@ relation.labelId = contact.Relation.RELATION_ASSISTANT;
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
var
sipAddress
=
{
var
sipAddress
=
{
sipAddress:
"sipAddress"
sipAddress:
"sipAddress"
}
;
}
;
...
@@ -2129,7 +2129,7 @@ var sipAddress = {
...
@@ -2129,7 +2129,7 @@ var sipAddress = {
或使用new一个SipAddress对象的方式创建数据:
或使用new一个SipAddress对象的方式创建数据:
```
```
js
let
sipAddress
=
new
contact
.
SipAddress
();
let
sipAddress
=
new
contact
.
SipAddress
();
sipAddress
.
sipAddress
=
"
sipAddress
"
;
sipAddress
.
sipAddress
=
"
sipAddress
"
;
```
```
...
@@ -2150,7 +2150,7 @@ sipAddress.sipAddress = "sipAddress";
...
@@ -2150,7 +2150,7 @@ sipAddress.sipAddress = "sipAddress";
使用JSON格式创建数据:
使用JSON格式创建数据:
```
```
json
let
website
=
{
let
website
=
{
website:
"website"
website:
"website"
}
;
}
;
...
@@ -2158,7 +2158,7 @@ let website = {
...
@@ -2158,7 +2158,7 @@ let website = {
或使用new一个Website对象的方式创建数据:
或使用new一个Website对象的方式创建数据:
```
```
js
let
website
=
new
contact
.
Website
();
let
website
=
new
contact
.
Website
();
website
.
website
=
"
website
"
;
website
.
website
=
"
website
"
;
```
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-convertxml.md
浏览文件 @
6acf3db4
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
## 导入模块
## 导入模块
```
```
js
import
convertxml
from
'
@ohos.convertxml
'
;
import
convertxml
from
'
@ohos.convertxml
'
;
```
```
...
...
zh-cn/application-dev/reference/apis/js-apis-faultLogger.md
浏览文件 @
6acf3db4
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
## 导入模块
## 导入模块
```
```
js
import
faultLogger
from
'
@ohos.faultLogger
'
import
faultLogger
from
'
@ohos.faultLogger
'
```
```
...
@@ -56,7 +56,7 @@ querySelfFaultLog(faultType: FaultType, callback: AsyncCallback<Array<Faul
...
@@ -56,7 +56,7 @@ querySelfFaultLog(faultType: FaultType, callback: AsyncCallback<Array<Faul
**示例:**
**示例:**
```
```
js
function
queryFaultLogCallback
(
error
,
value
)
{
function
queryFaultLogCallback
(
error
,
value
)
{
if
(
error
)
{
if
(
error
)
{
console
.
info
(
'
error is
'
+
error
);
console
.
info
(
'
error is
'
+
error
);
...
@@ -101,7 +101,7 @@ querySelfFaultLog(faultType: FaultType) : Promise<Array<FaultLogInfo>&g
...
@@ -101,7 +101,7 @@ querySelfFaultLog(faultType: FaultType) : Promise<Array<FaultLogInfo>&g
**示例:**
**示例:**
```
```
js
async
function
getLog
()
{
async
function
getLog
()
{
let
value
=
await
faultLogger
.
querySelfFaultLog
(
faultLogger
.
FaultType
.
JS_CRASH
);
let
value
=
await
faultLogger
.
querySelfFaultLog
(
faultLogger
.
FaultType
.
JS_CRASH
);
if
(
value
)
{
if
(
value
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-http.md
浏览文件 @
6acf3db4
...
@@ -7,13 +7,13 @@
...
@@ -7,13 +7,13 @@
## 导入模块
## 导入模块
```
```
js
import
http
from
'
@ohos.net.http
'
;
import
http
from
'
@ohos.net.http
'
;
```
```
## 完整示例
## 完整示例
```
```
js
import
http
from
'
@ohos.net.http
'
;
import
http
from
'
@ohos.net.http
'
;
// 每一个httpRequest对应一个http请求任务,不可复用
// 每一个httpRequest对应一个http请求任务,不可复用
...
@@ -71,7 +71,7 @@ createHttp\(\): HttpRequest
...
@@ -71,7 +71,7 @@ createHttp\(\): HttpRequest
**示例:**
**示例:**
```
```
js
import
http
from
'
@ohos.net.http
'
;
import
http
from
'
@ohos.net.http
'
;
let
httpRequest
=
http
.
createHttp
();
let
httpRequest
=
http
.
createHttp
();
```
```
...
@@ -100,7 +100,7 @@ request\(url: string, callback: AsyncCallback\<HttpResponse\>\):void
...
@@ -100,7 +100,7 @@ request\(url: string, callback: AsyncCallback\<HttpResponse\>\):void
**示例:**
**示例:**
```
```
js
httpRequest
.
request
(
"
EXAMPLE_URL
"
,
(
err
,
data
)
=>
{
httpRequest
.
request
(
"
EXAMPLE_URL
"
,
(
err
,
data
)
=>
{
if
(
!
err
)
{
if
(
!
err
)
{
console
.
info
(
'
Result:
'
+
data
.
result
);
console
.
info
(
'
Result:
'
+
data
.
result
);
...
@@ -133,7 +133,7 @@ request\(url: string, options: HttpRequestOptions, callback: AsyncCallback<HttpR
...
@@ -133,7 +133,7 @@ request\(url: string, options: HttpRequestOptions, callback: AsyncCallback<HttpR
**示例:**
**示例:**
```
```
js
httpRequest
.
request
(
"
EXAMPLE_URL
"
,
httpRequest
.
request
(
"
EXAMPLE_URL
"
,
{
{
method
:
http
.
RequestMethod
.
GET
,
method
:
http
.
RequestMethod
.
GET
,
...
@@ -183,7 +183,7 @@ request\(url: string, options? : HttpRequestOptions\): Promise<HttpResponse\>
...
@@ -183,7 +183,7 @@ request\(url: string, options? : HttpRequestOptions\): Promise<HttpResponse\>
**示例:**
**示例:**
```
```
js
let
promise
=
httpRequest
.
request
(
"
EXAMPLE_URL
"
,
{
let
promise
=
httpRequest
.
request
(
"
EXAMPLE_URL
"
,
{
method
:
http
.
RequestMethod
.
GET
,
method
:
http
.
RequestMethod
.
GET
,
connectTimeout
:
60000
,
connectTimeout
:
60000
,
...
@@ -214,7 +214,7 @@ destroy\(\): void
...
@@ -214,7 +214,7 @@ destroy\(\): void
**示例:**
**示例:**
```
```
js
httpRequest
.
destroy
();
httpRequest
.
destroy
();
```
```
...
@@ -238,7 +238,7 @@ on\(type: 'headerReceive', callback: AsyncCallback<Object\>\): void
...
@@ -238,7 +238,7 @@ on\(type: 'headerReceive', callback: AsyncCallback<Object\>\): void
**示例:**
**示例:**
```
```
js
httpRequest
.
on
(
'
headerReceive
'
,
(
err
,
data
)
=>
{
httpRequest
.
on
(
'
headerReceive
'
,
(
err
,
data
)
=>
{
if
(
!
err
)
{
if
(
!
err
)
{
console
.
info
(
'
header:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
header:
'
+
JSON
.
stringify
(
data
));
...
@@ -272,7 +272,7 @@ off\(type: 'headerReceive', callback?: AsyncCallback<Object\>\): void
...
@@ -272,7 +272,7 @@ off\(type: 'headerReceive', callback?: AsyncCallback<Object\>\): void
**示例:**
**示例:**
```
```
js
httpRequest
.
off
(
'
headerReceive
'
);
httpRequest
.
off
(
'
headerReceive
'
);
```
```
...
@@ -293,7 +293,7 @@ on\(type: 'headersReceive', callback: Callback<Object\>\): void
...
@@ -293,7 +293,7 @@ on\(type: 'headersReceive', callback: Callback<Object\>\): void
**示例:**
**示例:**
```
```
js
httpRequest
.
on
(
'
headersReceive
'
,
(
header
)
=>
{
httpRequest
.
on
(
'
headersReceive
'
,
(
header
)
=>
{
console
.
info
(
'
header:
'
+
JSON
.
stringify
(
header
));
console
.
info
(
'
header:
'
+
JSON
.
stringify
(
header
));
});
});
...
@@ -320,7 +320,7 @@ off\(type: 'headersReceive', callback?: Callback<Object\>\): void
...
@@ -320,7 +320,7 @@ off\(type: 'headersReceive', callback?: Callback<Object\>\): void
**示例:**
**示例:**
```
```
js
httpRequest
.
off
(
'
headersReceive
'
);
httpRequest
.
off
(
'
headersReceive
'
);
```
```
...
@@ -341,7 +341,7 @@ once\(type: 'headersReceive', callback: Callback<Object\>\): void
...
@@ -341,7 +341,7 @@ once\(type: 'headersReceive', callback: Callback<Object\>\): void
**示例:**
**示例:**
```
```
js
httpRequest
.
once
(
'
headersReceive
'
,
(
header
)
=>
{
httpRequest
.
once
(
'
headersReceive
'
,
(
header
)
=>
{
console
.
info
(
'
header:
'
+
JSON
.
stringify
(
header
));
console
.
info
(
'
header:
'
+
JSON
.
stringify
(
header
));
});
});
...
...
zh-cn/application-dev/reference/apis/js-apis-net-connection.md
浏览文件 @
6acf3db4
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
## 导入模块
## 导入模块
```
j
avascript
```
j
s
import
connection
from
'
@ohos.net.connection
'
import
connection
from
'
@ohos.net.connection
'
```
```
...
@@ -29,7 +29,7 @@ getDefaultNet(callback: AsyncCallback\<NetHandle>): void
...
@@ -29,7 +29,7 @@ getDefaultNet(callback: AsyncCallback\<NetHandle>): void
**示例:**
**示例:**
```
j
avascript
```
j
s
connection
.
getDefaultNet
(
function
(
error
,
netHandle
)
{
connection
.
getDefaultNet
(
function
(
error
,
netHandle
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
netHandle
))
console
.
log
(
JSON
.
stringify
(
netHandle
))
...
@@ -54,7 +54,7 @@ getDefaultNet(): Promise\<NetHandle>
...
@@ -54,7 +54,7 @@ getDefaultNet(): Promise\<NetHandle>
**示例:**
**示例:**
```
j
avascript
```
j
s
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
console
.
log
(
JSON
.
stringify
(
netHandle
))
console
.
log
(
JSON
.
stringify
(
netHandle
))
})
})
...
@@ -76,7 +76,7 @@ hasDefaultNet(callback: AsyncCallback\<boolean>): void
...
@@ -76,7 +76,7 @@ hasDefaultNet(callback: AsyncCallback\<boolean>): void
**示例:**
**示例:**
```
j
avascript
```
j
s
connection
.
hasDefaultNet
(
function
(
error
,
has
)
{
connection
.
hasDefaultNet
(
function
(
error
,
has
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
has
)
console
.
log
(
has
)
...
@@ -99,7 +99,7 @@ hasDefaultNet(): Promise\<boolean>
...
@@ -99,7 +99,7 @@ hasDefaultNet(): Promise\<boolean>
**示例:**
**示例:**
```
j
avascript
```
j
s
connection
.
hasDefaultNet
().
then
(
function
(
has
)
{
connection
.
hasDefaultNet
().
then
(
function
(
has
)
{
console
.
log
(
has
)
console
.
log
(
has
)
})
})
...
@@ -122,7 +122,7 @@ getAllNets(callback: AsyncCallback<Array<NetHandle>>): void
...
@@ -122,7 +122,7 @@ getAllNets(callback: AsyncCallback<Array<NetHandle>>): void
**示例:**
**示例:**
```
```
js
connection
.
getAllNets
(
function
(
error
,
nets
)
{
connection
.
getAllNets
(
function
(
error
,
nets
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
nets
))
console
.
log
(
JSON
.
stringify
(
nets
))
...
@@ -147,7 +147,7 @@ getAllNets(): Promise<Array<NetHandle>>
...
@@ -147,7 +147,7 @@ getAllNets(): Promise<Array<NetHandle>>
**示例:**
**示例:**
```
```
js
connection
.
getAllNets
().
then
(
function
(
nets
)
{
connection
.
getAllNets
().
then
(
function
(
nets
)
{
console
.
log
(
JSON
.
stringify
(
nets
))
console
.
log
(
JSON
.
stringify
(
nets
))
});
});
...
@@ -172,7 +172,7 @@ getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\<Connectio
...
@@ -172,7 +172,7 @@ getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\<Connectio
**示例:**
**示例:**
```
j
avascript
```
j
s
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getConnectionProperties
(
netHandle
,
function
(
error
,
info
)
{
connection
.
getConnectionProperties
(
netHandle
,
function
(
error
,
info
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
error
))
...
@@ -205,7 +205,7 @@ getConnectionProperties(netHandle: NetHandle): Promise\<ConnectionProperties>
...
@@ -205,7 +205,7 @@ getConnectionProperties(netHandle: NetHandle): Promise\<ConnectionProperties>
**示例:**
**示例:**
```
j
avascript
```
j
s
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getConnectionProperties
(
netHandle
).
then
(
function
(
info
)
{
connection
.
getConnectionProperties
(
netHandle
).
then
(
function
(
info
)
{
console
.
log
(
JSON
.
stringify
(
info
))
console
.
log
(
JSON
.
stringify
(
info
))
...
@@ -232,7 +232,7 @@ getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\<NetCapabilitie
...
@@ -232,7 +232,7 @@ getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\<NetCapabilitie
**示例:**
**示例:**
```
j
avascript
```
j
s
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getNetCapabilities
(
netHandle
,
function
(
error
,
info
)
{
connection
.
getNetCapabilities
(
netHandle
,
function
(
error
,
info
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
error
))
...
@@ -265,7 +265,7 @@ getNetCapabilities(netHandle: NetHandle): Promise\<NetCapabilities>
...
@@ -265,7 +265,7 @@ getNetCapabilities(netHandle: NetHandle): Promise\<NetCapabilities>
**示例:**
**示例:**
```
j
avascript
```
j
s
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getNetCapabilities
(
netHandle
).
then
(
function
(
info
)
{
connection
.
getNetCapabilities
(
netHandle
).
then
(
function
(
info
)
{
console
.
log
(
JSON
.
stringify
(
info
))
console
.
log
(
JSON
.
stringify
(
info
))
...
@@ -291,7 +291,7 @@ reportNetConnected(netHandle: NetHandle, callback: AsyncCallback<void>): v
...
@@ -291,7 +291,7 @@ reportNetConnected(netHandle: NetHandle, callback: AsyncCallback<void>): v
**示例:**
**示例:**
```
```
js
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
reportNetConnected
(
netHandle
,
function
(
error
)
{
connection
.
reportNetConnected
(
netHandle
,
function
(
error
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
error
))
...
@@ -322,7 +322,7 @@ reportNetConnected(netHandle: NetHandle): Promise<void>
...
@@ -322,7 +322,7 @@ reportNetConnected(netHandle: NetHandle): Promise<void>
**示例:**
**示例:**
```
```
js
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
reportNetConnected
(
netHandle
).
then
(
function
()
{
connection
.
reportNetConnected
(
netHandle
).
then
(
function
()
{
console
.
log
(
`report success`
)
console
.
log
(
`report success`
)
...
@@ -349,7 +349,7 @@ reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback<void>)
...
@@ -349,7 +349,7 @@ reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback<void>)
**示例:**
**示例:**
```
```
js
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
reportNetDisconnected
(
netHandle
,
function
(
error
)
{
connection
.
reportNetDisconnected
(
netHandle
,
function
(
error
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
error
))
...
@@ -380,7 +380,7 @@ reportNetDisconnected(netHandle: NetHandle): Promise<void>
...
@@ -380,7 +380,7 @@ reportNetDisconnected(netHandle: NetHandle): Promise<void>
**示例:**
**示例:**
```
```
js
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
reportNetDisconnected
(
netHandle
).
then
(
function
()
{
connection
.
reportNetDisconnected
(
netHandle
).
then
(
function
()
{
console
.
log
(
`report success`
)
console
.
log
(
`report success`
)
...
@@ -407,7 +407,7 @@ getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>):
...
@@ -407,7 +407,7 @@ getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>):
**示例:**
**示例:**
```
```
js
let
host
=
"
xxxx
"
;
let
host
=
"
xxxx
"
;
connection
.
getAddressesByName
(
host
,
function
(
error
,
addresses
)
{
connection
.
getAddressesByName
(
host
,
function
(
error
,
addresses
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
error
))
...
@@ -439,7 +439,7 @@ getAddressesByName(host: string): Promise\<Array\<NetAddress>>
...
@@ -439,7 +439,7 @@ getAddressesByName(host: string): Promise\<Array\<NetAddress>>
**示例:**
**示例:**
```
```
js
let
host
=
"
xxxx
"
;
let
host
=
"
xxxx
"
;
connection
.
getAddressesByName
(
host
).
then
(
function
(
addresses
)
{
connection
.
getAddressesByName
(
host
).
then
(
function
(
addresses
)
{
console
.
log
(
JSON
.
stringify
(
addresses
))
console
.
log
(
JSON
.
stringify
(
addresses
))
...
@@ -469,7 +469,7 @@ createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnectio
...
@@ -469,7 +469,7 @@ createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnectio
**示例:**
**示例:**
```
j
avascript
```
j
s
// 关注默认网络
// 关注默认网络
let
netConnection
=
connection
.
createNetConnection
()
let
netConnection
=
connection
.
createNetConnection
()
...
@@ -502,7 +502,7 @@ on(type: 'netAvailable', callback: Callback\<NetHandle>): void
...
@@ -502,7 +502,7 @@ on(type: 'netAvailable', callback: Callback\<NetHandle>): void
**示例:**
**示例:**
```
j
avascript
```
j
s
netConnection
.
on
(
'
netAvailable
'
,
function
(
data
)
{
netConnection
.
on
(
'
netAvailable
'
,
function
(
data
)
{
console
.
log
(
JSON
.
stringify
(
data
))
console
.
log
(
JSON
.
stringify
(
data
))
})
})
...
@@ -525,7 +525,7 @@ on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, net
...
@@ -525,7 +525,7 @@ on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, net
**示例:**
**示例:**
```
j
avascript
```
j
s
netConnection
.
on
(
'
netCapabilitiesChange
'
,
function
(
data
)
{
netConnection
.
on
(
'
netCapabilitiesChange
'
,
function
(
data
)
{
console
.
log
(
JSON
.
stringify
(
data
))
console
.
log
(
JSON
.
stringify
(
data
))
})
})
...
@@ -548,7 +548,7 @@ on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHan
...
@@ -548,7 +548,7 @@ on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHan
**示例:**
**示例:**
```
j
avascript
```
j
s
netConnection
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
data
)
{
netConnection
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
data
)
{
console
.
log
(
JSON
.
stringify
(
data
))
console
.
log
(
JSON
.
stringify
(
data
))
})
})
...
@@ -571,7 +571,7 @@ on(type: 'netBlockStatusChange', callback: Callback<{ netHandle: NetHandle, b
...
@@ -571,7 +571,7 @@ on(type: 'netBlockStatusChange', callback: Callback<{ netHandle: NetHandle, b
**示例:**
**示例:**
```
j
avascript
```
j
s
netConnection
.
on
(
'
netBlockStatusChange
'
,
function
(
data
)
{
netConnection
.
on
(
'
netBlockStatusChange
'
,
function
(
data
)
{
console
.
log
(
JSON
.
stringify
(
data
))
console
.
log
(
JSON
.
stringify
(
data
))
})
})
...
@@ -594,7 +594,7 @@ on(type: 'netLost', callback: Callback\<NetHandle>): void
...
@@ -594,7 +594,7 @@ on(type: 'netLost', callback: Callback\<NetHandle>): void
**示例:**
**示例:**
```
j
avascript
```
j
s
let
netConnection1
=
connection
.
createNetConnection
()
let
netConnection1
=
connection
.
createNetConnection
()
netConnection1
.
on
(
'
netLost
'
,
function
(
data
)
{
netConnection1
.
on
(
'
netLost
'
,
function
(
data
)
{
console
.
log
(
JSON
.
stringify
(
data
))
console
.
log
(
JSON
.
stringify
(
data
))
...
@@ -618,7 +618,7 @@ on(type: 'netUnavailable', callback: Callback\<void>): void
...
@@ -618,7 +618,7 @@ on(type: 'netUnavailable', callback: Callback\<void>): void
**示例:**
**示例:**
```
j
avascript
```
j
s
netConnection
.
on
(
'
netUnavailable
'
,
function
(
data
)
{
netConnection
.
on
(
'
netUnavailable
'
,
function
(
data
)
{
console
.
log
(
JSON
.
stringify
(
data
))
console
.
log
(
JSON
.
stringify
(
data
))
})
})
...
@@ -642,7 +642,7 @@ register(callback: AsyncCallback\<void>): void
...
@@ -642,7 +642,7 @@ register(callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
j
avascript
```
j
s
netConnection
.
register
(
function
(
error
)
{
netConnection
.
register
(
function
(
error
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
error
))
})
})
...
@@ -664,7 +664,7 @@ unregister(callback: AsyncCallback\<void>): void
...
@@ -664,7 +664,7 @@ unregister(callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
j
avascript
```
j
s
netConnection
.
unregister
(
function
(
error
)
{
netConnection
.
unregister
(
function
(
error
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
error
))
})
})
...
@@ -703,7 +703,7 @@ getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>):
...
@@ -703,7 +703,7 @@ getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>):
**示例:**
**示例:**
```
j
avascript
```
j
s
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
let
host
=
"
xxxx
"
;
let
host
=
"
xxxx
"
;
netHandle
.
getAddressesByName
(
host
,
function
(
error
,
addresses
)
{
netHandle
.
getAddressesByName
(
host
,
function
(
error
,
addresses
)
{
...
@@ -737,7 +737,7 @@ getAddressesByName(host: string): Promise\<Array\<NetAddress>>
...
@@ -737,7 +737,7 @@ getAddressesByName(host: string): Promise\<Array\<NetAddress>>
**示例:**
**示例:**
```
j
avascript
```
j
s
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
let
host
=
"
xxxx
"
;
let
host
=
"
xxxx
"
;
netHandle
.
getAddressesByName
(
host
).
then
(
function
(
addresses
)
{
netHandle
.
getAddressesByName
(
host
).
then
(
function
(
addresses
)
{
...
@@ -765,7 +765,7 @@ getAddressByName(host: string, callback: AsyncCallback\<NetAddress>): void
...
@@ -765,7 +765,7 @@ getAddressByName(host: string, callback: AsyncCallback\<NetAddress>): void
**示例:**
**示例:**
```
j
avascript
```
j
s
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
let
host
=
"
xxxx
"
;
let
host
=
"
xxxx
"
;
netHandle
.
getAddressByName
(
host
,
function
(
error
,
address
)
{
netHandle
.
getAddressByName
(
host
,
function
(
error
,
address
)
{
...
@@ -799,7 +799,7 @@ getAddressByName(host: string): Promise\<NetAddress>
...
@@ -799,7 +799,7 @@ getAddressByName(host: string): Promise\<NetAddress>
**示例:**
**示例:**
```
j
avascript
```
j
s
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
connection
.
getDefaultNet
().
then
(
function
(
netHandle
)
{
let
host
=
"
xxxx
"
;
let
host
=
"
xxxx
"
;
netHandle
.
getAddressByName
(
host
).
then
(
function
(
address
)
{
netHandle
.
getAddressByName
(
host
).
then
(
function
(
address
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-observer.md
浏览文件 @
6acf3db4
...
@@ -30,7 +30,7 @@ on\(type: \'networkStateChange\', callback: Callback<NetworkState\>\): void;
...
@@ -30,7 +30,7 @@ on\(type: \'networkStateChange\', callback: Callback<NetworkState\>\): void;
**示例:**
**示例:**
```
```
js
observer
.
on
(
'
networkStateChange
'
,
data
=>
{
observer
.
on
(
'
networkStateChange
'
,
data
=>
{
console
.
log
(
"
on networkStateChange, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
on networkStateChange, data:
"
+
JSON
.
stringify
(
data
));
});
});
...
@@ -57,7 +57,7 @@ on\(type: \'networkStateChange\', options: { slotId: number }, callback: Callbac
...
@@ -57,7 +57,7 @@ on\(type: \'networkStateChange\', options: { slotId: number }, callback: Callbac
**示例:**
**示例:**
```
```
js
observer
.
on
(
'
networkStateChange
'
,
{
slotId
:
0
},
data
=>
{
observer
.
on
(
'
networkStateChange
'
,
{
slotId
:
0
},
data
=>
{
console
.
log
(
"
on networkStateChange, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
on networkStateChange, data:
"
+
JSON
.
stringify
(
data
));
});
});
...
@@ -87,7 +87,7 @@ off\(type: \'networkStateChange\', callback?: Callback<NetworkState\>\): void;
...
@@ -87,7 +87,7 @@ off\(type: \'networkStateChange\', callback?: Callback<NetworkState\>\): void;
**示例:**
**示例:**
```
```
js
let
callback
=
data
=>
{
let
callback
=
data
=>
{
console
.
log
(
"
on networkStateChange, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
on networkStateChange, data:
"
+
JSON
.
stringify
(
data
));
}
}
...
@@ -114,7 +114,7 @@ on\(type: \'signalInfoChange\', callback: Callback<Array<SignalInformation\>\>):
...
@@ -114,7 +114,7 @@ on\(type: \'signalInfoChange\', callback: Callback<Array<SignalInformation\>\>):
**示例:**
**示例:**
```
```
js
observer
.
on
(
'
signalInfoChange
'
,
data
=>
{
observer
.
on
(
'
signalInfoChange
'
,
data
=>
{
console
.
log
(
"
on signalInfoChange, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
on signalInfoChange, data:
"
+
JSON
.
stringify
(
data
));
});
});
...
@@ -139,7 +139,7 @@ on\(type: \'signalInfoChange\', options: { slotId: number }, callback: Callback<
...
@@ -139,7 +139,7 @@ on\(type: \'signalInfoChange\', options: { slotId: number }, callback: Callback<
**示例:**
**示例:**
```
```
js
observer
.
on
(
'
signalInfoChange
'
,
{
slotId
:
0
},
data
=>
{
observer
.
on
(
'
signalInfoChange
'
,
{
slotId
:
0
},
data
=>
{
console
.
log
(
"
on signalInfoChange, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
on signalInfoChange, data:
"
+
JSON
.
stringify
(
data
));
});
});
...
@@ -167,7 +167,7 @@ off\(type: \'signalInfoChange\', callback?: Callback<Array<SignalInformation\>\>
...
@@ -167,7 +167,7 @@ off\(type: \'signalInfoChange\', callback?: Callback<Array<SignalInformation\>\>
**示例:**
**示例:**
```
```
js
let
callback
=
data
=>
{
let
callback
=
data
=>
{
console
.
log
(
"
on signalInfoChange, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
on signalInfoChange, data:
"
+
JSON
.
stringify
(
data
));
}
}
...
@@ -197,7 +197,7 @@ on(type: 'callStateChange', callback: Callback\<{ state: CallState, number: stri
...
@@ -197,7 +197,7 @@ on(type: 'callStateChange', callback: Callback\<{ state: CallState, number: stri
**示例:**
**示例:**
```
```
js
observer
.
on
(
'
callStateChange
'
,
value
=>
{
observer
.
on
(
'
callStateChange
'
,
value
=>
{
console
.
log
(
"
on callStateChange, state:
"
+
value
.
state
+
"
, number:
"
+
value
.
number
);
console
.
log
(
"
on callStateChange, state:
"
+
value
.
state
+
"
, number:
"
+
value
.
number
);
});
});
...
@@ -224,7 +224,7 @@ on(type: 'callStateChange', options: { slotId: number }, callback: Callback<{ st
...
@@ -224,7 +224,7 @@ on(type: 'callStateChange', options: { slotId: number }, callback: Callback<{ st
**示例:**
**示例:**
```
```
js
observer
.
on
(
'
callStateChange
'
,
{
slotId
:
0
},
value
=>
{
observer
.
on
(
'
callStateChange
'
,
{
slotId
:
0
},
value
=>
{
console
.
log
(
"
on callStateChange, state:
"
+
value
.
state
+
"
, number:
"
+
value
.
number
);
console
.
log
(
"
on callStateChange, state:
"
+
value
.
state
+
"
, number:
"
+
value
.
number
);
});
});
...
@@ -254,7 +254,7 @@ off(type: 'callStateChange', callback?: Callback<{ state: CallState, number: str
...
@@ -254,7 +254,7 @@ off(type: 'callStateChange', callback?: Callback<{ state: CallState, number: str
**示例:**
**示例:**
```
```
js
let
callback
=
value
=>
{
let
callback
=
value
=>
{
console
.
log
(
"
on callStateChange, state:
"
+
value
.
state
+
"
, number:
"
+
value
.
number
);
console
.
log
(
"
on callStateChange, state:
"
+
value
.
state
+
"
, number:
"
+
value
.
number
);
}
}
...
@@ -282,7 +282,7 @@ on\(type: 'cellularDataConnectionStateChange', callback: Callback\<{ state: Data
...
@@ -282,7 +282,7 @@ on\(type: 'cellularDataConnectionStateChange', callback: Callback\<{ state: Data
**示例:**
**示例:**
```
```
js
observer
.
on
(
'
cellularDataConnectionStateChange
'
,
value
=>
{
observer
.
on
(
'
cellularDataConnectionStateChange
'
,
value
=>
{
console
.
log
(
"
on cellularDataConnectionStateChange, state:
"
+
value
.
state
+
"
, network:
"
+
value
.
network
);
console
.
log
(
"
on cellularDataConnectionStateChange, state:
"
+
value
.
state
+
"
, network:
"
+
value
.
network
);
});
});
...
@@ -307,7 +307,7 @@ on\(type: 'cellularDataConnectionStateChange', options: { slotId: number }, call
...
@@ -307,7 +307,7 @@ on\(type: 'cellularDataConnectionStateChange', options: { slotId: number }, call
**示例:**
**示例:**
```
```
js
observer
.
on
(
'
cellularDataConnectionStateChange
'
,
{
slotId
:
0
},
value
=>
{
observer
.
on
(
'
cellularDataConnectionStateChange
'
,
{
slotId
:
0
},
value
=>
{
console
.
log
(
"
on cellularDataConnectionStateChange, state:
"
+
value
.
state
+
"
, network:
"
+
value
.
network
);
console
.
log
(
"
on cellularDataConnectionStateChange, state:
"
+
value
.
state
+
"
, network:
"
+
value
.
network
);
});
});
...
@@ -335,7 +335,7 @@ off\(type: 'cellularDataConnectionStateChange', callback?: Callback\<{ state: D
...
@@ -335,7 +335,7 @@ off\(type: 'cellularDataConnectionStateChange', callback?: Callback\<{ state: D
**示例:**
**示例:**
```
```
js
let
callback
=
value
=>
{
let
callback
=
value
=>
{
console
.
log
(
"
on cellularDataConnectionStateChange, state:
"
+
value
.
state
+
"
, network:
"
+
value
.
network
);
console
.
log
(
"
on cellularDataConnectionStateChange, state:
"
+
value
.
state
+
"
, network:
"
+
value
.
network
);
}
}
...
@@ -363,7 +363,7 @@ on\(type: 'cellularDataFlowChange', callback: Callback\<DataFlowType\>\): void;
...
@@ -363,7 +363,7 @@ on\(type: 'cellularDataFlowChange', callback: Callback\<DataFlowType\>\): void;
**示例:**
**示例:**
```
```
js
observer
.
on
(
'
cellularDataFlowChange
'
,
data
=>
{
observer
.
on
(
'
cellularDataFlowChange
'
,
data
=>
{
console
.
log
(
"
on networkStateChange, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
on networkStateChange, data:
"
+
JSON
.
stringify
(
data
));
});
});
...
@@ -388,7 +388,7 @@ on\(type: 'cellularDataFlowChange', options: { slotId: number }, callback: Call
...
@@ -388,7 +388,7 @@ on\(type: 'cellularDataFlowChange', options: { slotId: number }, callback: Call
**示例:**
**示例:**
```
```
js
observer
.
on
(
'
cellularDataFlowChange
'
,
{
slotId
:
0
},
data
=>
{
observer
.
on
(
'
cellularDataFlowChange
'
,
{
slotId
:
0
},
data
=>
{
console
.
log
(
"
on cellularDataFlowChange, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
on cellularDataFlowChange, data:
"
+
JSON
.
stringify
(
data
));
});
});
...
@@ -416,7 +416,7 @@ off\(type: 'cellularDataFlowChange', callback?: Callback\<DataFlowType\>\): void
...
@@ -416,7 +416,7 @@ off\(type: 'cellularDataFlowChange', callback?: Callback\<DataFlowType\>\): void
**示例:**
**示例:**
```
```
js
let
callback
=
data
=>
{
let
callback
=
data
=>
{
console
.
log
(
"
on cellularDataFlowChange, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
on cellularDataFlowChange, data:
"
+
JSON
.
stringify
(
data
));
}
}
...
@@ -444,7 +444,7 @@ on\(type: 'simStateChange', callback: Callback\<SimStateData\>\): void;
...
@@ -444,7 +444,7 @@ on\(type: 'simStateChange', callback: Callback\<SimStateData\>\): void;
**示例:**
**示例:**
```
```
js
observer
.
on
(
'
simStateChange
'
,
data
=>
{
observer
.
on
(
'
simStateChange
'
,
data
=>
{
console
.
log
(
"
on simStateChange, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
on simStateChange, data:
"
+
JSON
.
stringify
(
data
));
});
});
...
@@ -469,7 +469,7 @@ on\(type: 'simStateChange', options: { slotId: number }, callback: Callback\<Sim
...
@@ -469,7 +469,7 @@ on\(type: 'simStateChange', options: { slotId: number }, callback: Callback\<Sim
**示例:**
**示例:**
```
```
js
observer
.
on
(
'
simStateChange
'
,
{
slotId
:
0
},
data
=>
{
observer
.
on
(
'
simStateChange
'
,
{
slotId
:
0
},
data
=>
{
console
.
log
(
"
on simStateChange, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
on simStateChange, data:
"
+
JSON
.
stringify
(
data
));
});
});
...
@@ -497,7 +497,7 @@ off\(type: 'simStateChange', callback?: Callback\<SimStateData\>\): void;
...
@@ -497,7 +497,7 @@ off\(type: 'simStateChange', callback?: Callback\<SimStateData\>\): void;
**示例:**
**示例:**
```
```
js
let
callback
=
data
=>
{
let
callback
=
data
=>
{
console
.
log
(
"
on simStateChange, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
on simStateChange, data:
"
+
JSON
.
stringify
(
data
));
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-radio.md
浏览文件 @
6acf3db4
...
@@ -30,7 +30,7 @@ getRadioTech\(slotId: number, callback: AsyncCallback<\{psRadioTech: RadioTechno
...
@@ -30,7 +30,7 @@ getRadioTech\(slotId: number, callback: AsyncCallback<\{psRadioTech: RadioTechno
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
radio
.
getRadioTech
(
slotId
,
(
err
,
data
)
=>
{
radio
.
getRadioTech
(
slotId
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -62,7 +62,7 @@ getRadioTech\(slotId: number\): Promise<\{psRadioTech: RadioTechnology, csRadioT
...
@@ -62,7 +62,7 @@ getRadioTech\(slotId: number\): Promise<\{psRadioTech: RadioTechnology, csRadioT
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
let
promise
=
radio
.
getRadioTech
(
slotId
);
let
promise
=
radio
.
getRadioTech
(
slotId
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
...
@@ -91,7 +91,7 @@ getNetworkState\(callback: AsyncCallback<NetworkState\>\): void
...
@@ -91,7 +91,7 @@ getNetworkState\(callback: AsyncCallback<NetworkState\>\): void
**示例:**
**示例:**
```
```
js
radio
.
getNetworkState
((
err
,
data
)
=>
{
radio
.
getNetworkState
((
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -117,7 +117,7 @@ getNetworkState\(slotId: number, callback: AsyncCallback<NetworkState\>\): void
...
@@ -117,7 +117,7 @@ getNetworkState\(slotId: number, callback: AsyncCallback<NetworkState\>\): void
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
radio
.
getNetworkState
(
slotId
,
(
err
,
data
)
=>
{
radio
.
getNetworkState
(
slotId
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -149,7 +149,7 @@ getNetworkState\(slotId?: number\): Promise<NetworkState\>
...
@@ -149,7 +149,7 @@ getNetworkState\(slotId?: number\): Promise<NetworkState\>
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
let
promise
=
radio
.
getNetworkState
(
slotId
);
let
promise
=
radio
.
getNetworkState
(
slotId
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
...
@@ -177,7 +177,7 @@ getNetworkSelectionMode\(slotId: number, callback: AsyncCallback<NetworkSelectio
...
@@ -177,7 +177,7 @@ getNetworkSelectionMode\(slotId: number, callback: AsyncCallback<NetworkSelectio
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
radio
.
getNetworkSelectionMode
(
slotId
,
(
err
,
data
)
=>
{
radio
.
getNetworkSelectionMode
(
slotId
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -207,7 +207,7 @@ getNetworkSelectionMode\(slotId: number\): Promise<NetworkSelectionMode\>
...
@@ -207,7 +207,7 @@ getNetworkSelectionMode\(slotId: number\): Promise<NetworkSelectionMode\>
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
let
promise
=
radio
.
getNetworkSelectionMode
(
slotId
);
let
promise
=
radio
.
getNetworkSelectionMode
(
slotId
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
...
@@ -235,7 +235,7 @@ getISOCountryCodeForNetwork\(slotId: number, callback: AsyncCallback<string\>\):
...
@@ -235,7 +235,7 @@ getISOCountryCodeForNetwork\(slotId: number, callback: AsyncCallback<string\>\):
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
radio
.
getISOCountryCodeForNetwork
(
slotId
,
(
err
,
data
)
=>
{
radio
.
getISOCountryCodeForNetwork
(
slotId
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -265,7 +265,7 @@ getISOCountryCodeForNetwork\(slotId: number\): Promise<string\>
...
@@ -265,7 +265,7 @@ getISOCountryCodeForNetwork\(slotId: number\): Promise<string\>
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
let
promise
=
radio
.
getISOCountryCodeForNetwork
(
slotId
);
let
promise
=
radio
.
getISOCountryCodeForNetwork
(
slotId
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
...
@@ -292,7 +292,7 @@ getPrimarySlotId\(callback: AsyncCallback\<number\>\): void
...
@@ -292,7 +292,7 @@ getPrimarySlotId\(callback: AsyncCallback\<number\>\): void
**示例:**
**示例:**
```
```
js
radio
.
getPrimarySlotId
((
err
,
data
)
=>
{
radio
.
getPrimarySlotId
((
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -315,7 +315,7 @@ getPrimarySlotId\(\): Promise\<number\>
...
@@ -315,7 +315,7 @@ getPrimarySlotId\(\): Promise\<number\>
**示例:**
**示例:**
```
```
js
let
promise
=
radio
.
getPrimarySlotId
();
let
promise
=
radio
.
getPrimarySlotId
();
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`getPrimarySlotId success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`getPrimarySlotId success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -342,7 +342,7 @@ getSignalInformation\(slotId: number, callback: AsyncCallback<Array<SignalInform
...
@@ -342,7 +342,7 @@ getSignalInformation\(slotId: number, callback: AsyncCallback<Array<SignalInform
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
radio
.
getSignalInformation
(
slotId
,
(
err
,
data
)
=>
{
radio
.
getSignalInformation
(
slotId
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -372,7 +372,7 @@ getSignalInformation\(slotId: number\): Promise<Array<SignalInformation\>\>
...
@@ -372,7 +372,7 @@ getSignalInformation\(slotId: number\): Promise<Array<SignalInformation\>\>
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
let
promise
=
radio
.
getSignalInformation
(
slotId
);
let
promise
=
radio
.
getSignalInformation
(
slotId
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
...
@@ -405,7 +405,7 @@ isNrSupported\(slotId: number\): boolean
...
@@ -405,7 +405,7 @@ isNrSupported\(slotId: number\): boolean
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
let
result
=
radio
.
isNrSupported
(
slotId
);
let
result
=
radio
.
isNrSupported
(
slotId
);
console
.
log
(
result
);
console
.
log
(
result
);
...
@@ -430,7 +430,7 @@ isRadioOn\(callback: AsyncCallback<boolean\>\): void
...
@@ -430,7 +430,7 @@ isRadioOn\(callback: AsyncCallback<boolean\>\): void
**示例:**
**示例:**
```
```
js
radio
.
isRadioOn
((
err
,
data
)
=>
{
radio
.
isRadioOn
((
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -456,7 +456,7 @@ isRadioOn\(slotId: number, callback: AsyncCallback<boolean\>\): void
...
@@ -456,7 +456,7 @@ isRadioOn\(slotId: number, callback: AsyncCallback<boolean\>\): void
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
radio
.
isRadioOn
(
slotId
,
(
err
,
data
)
=>
{
radio
.
isRadioOn
(
slotId
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -488,7 +488,7 @@ isRadioOn\(slotId?: number\): Promise<boolean\>
...
@@ -488,7 +488,7 @@ isRadioOn\(slotId?: number\): Promise<boolean\>
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
let
promise
=
radio
.
isRadioOn
(
slotId
);
let
promise
=
radio
.
isRadioOn
(
slotId
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
...
@@ -516,7 +516,7 @@ getOperatorName\(slotId: number, callback: AsyncCallback<string\>\): void
...
@@ -516,7 +516,7 @@ getOperatorName\(slotId: number, callback: AsyncCallback<string\>\): void
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
radio
.
getOperatorName
(
slotId
,
(
err
,
data
)
=>
{
radio
.
getOperatorName
(
slotId
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -546,7 +546,7 @@ getOperatorName\(slotId: number\): Promise<string\>
...
@@ -546,7 +546,7 @@ getOperatorName\(slotId: number\): Promise<string\>
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
let
promise
=
radio
.
getOperatorName
(
slotId
);
let
promise
=
radio
.
getOperatorName
(
slotId
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-request.md
浏览文件 @
6acf3db4
...
@@ -8,25 +8,25 @@
...
@@ -8,25 +8,25 @@
## 导入模块
## 导入模块
```
```
js
import
request
from
'
@ohos.request
'
;
import
request
from
'
@ohos.request
'
;
```
```
## 限制与约束
## 限制与约束
-
默认支持https,如果要支持http,需要在config.json里增加network标签,属性标识 "cleartextTraffic": true。即:
默认支持https,如果要支持http,需要在config.json里增加network标签,属性标识 "cleartextTraffic": true。即:
```
```
"deviceConfig": {
"deviceConfig": {
"default": {
"default": {
"network": {
"network": {
"cleartextTraffic": true
"cleartextTraffic": true
}
...
}
}
...
}
}
```
}
```
## 常量
## 常量
...
...
zh-cn/application-dev/reference/apis/js-apis-sim.md
浏览文件 @
6acf3db4
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
## 导入模块
## 导入模块
```
```
js
import
sim
from
'
@ohos.telephony.sim
'
;
import
sim
from
'
@ohos.telephony.sim
'
;
```
```
...
@@ -28,7 +28,7 @@ isSimActive\(slotId: number, callback: AsyncCallback<boolean\>\): void
...
@@ -28,7 +28,7 @@ isSimActive\(slotId: number, callback: AsyncCallback<boolean\>\): void
**示例:**
**示例:**
```
```
js
sim
.
isSimActive
(
0
,
(
err
,
data
)
=>
{
sim
.
isSimActive
(
0
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -57,7 +57,7 @@ isSimActive\(slotId: number\): Promise<boolean\>
...
@@ -57,7 +57,7 @@ isSimActive\(slotId: number\): Promise<boolean\>
**示例:**
**示例:**
```
```
js
let
promise
=
sim
.
isSimActive
(
0
);
let
promise
=
sim
.
isSimActive
(
0
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`isSimActive success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`isSimActive success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -83,7 +83,7 @@ getDefaultVoiceSlotId\(callback: AsyncCallback<number\>\): void
...
@@ -83,7 +83,7 @@ getDefaultVoiceSlotId\(callback: AsyncCallback<number\>\): void
**示例:**
**示例:**
```
```
js
sim
.
getDefaultVoiceSlotId
((
err
,
data
)
=>
{
sim
.
getDefaultVoiceSlotId
((
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -106,7 +106,7 @@ getDefaultVoiceSlotId\(\): Promise<number\>
...
@@ -106,7 +106,7 @@ getDefaultVoiceSlotId\(\): Promise<number\>
**示例:**
**示例:**
```
```
js
let
promise
=
sim
.
getDefaultVoiceSlotId
();
let
promise
=
sim
.
getDefaultVoiceSlotId
();
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`getDefaultVoiceSlotId success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`getDefaultVoiceSlotId success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -132,7 +132,7 @@ hasOperatorPrivileges(slotId: number, callback: AsyncCallback\<boolean\>): void
...
@@ -132,7 +132,7 @@ hasOperatorPrivileges(slotId: number, callback: AsyncCallback\<boolean\>): void
**示例:**
**示例:**
```
```
js
sim
.
hasOperatorPrivileges
(
0
,
(
err
,
data
)
=>
{
sim
.
hasOperatorPrivileges
(
0
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -160,7 +160,7 @@ hasOperatorPrivileges(slotId: number): Promise<boolean\>
...
@@ -160,7 +160,7 @@ hasOperatorPrivileges(slotId: number): Promise<boolean\>
**示例:**
**示例:**
```
```
js
let
promise
=
sim
.
hasOperatorPrivileges
(
0
);
let
promise
=
sim
.
hasOperatorPrivileges
(
0
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`hasOperatorPrivileges success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`hasOperatorPrivileges success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -186,7 +186,7 @@ getISOCountryCodeForSim\(slotId: number, callback: AsyncCallback<string\>\): voi
...
@@ -186,7 +186,7 @@ getISOCountryCodeForSim\(slotId: number, callback: AsyncCallback<string\>\): voi
**示例:**
**示例:**
```
```
js
sim
.
getISOCountryCodeForSim
(
0
,
(
err
,
data
)
=>
{
sim
.
getISOCountryCodeForSim
(
0
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -215,7 +215,7 @@ getISOCountryCodeForSim\(slotId: number\): Promise<string\>
...
@@ -215,7 +215,7 @@ getISOCountryCodeForSim\(slotId: number\): Promise<string\>
**示例:**
**示例:**
```
```
js
let
promise
=
sim
.
getISOCountryCodeForSim
(
0
);
let
promise
=
sim
.
getISOCountryCodeForSim
(
0
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`getISOCountryCodeForSim success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`getISOCountryCodeForSim success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -242,7 +242,7 @@ getSimOperatorNumeric\(slotId: number, callback: AsyncCallback<string\>\): void
...
@@ -242,7 +242,7 @@ getSimOperatorNumeric\(slotId: number, callback: AsyncCallback<string\>\): void
**示例:**
**示例:**
```
```
js
sim
.
getSimOperatorNumeric
(
0
,
(
err
,
data
)
=>
{
sim
.
getSimOperatorNumeric
(
0
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -271,7 +271,7 @@ getSimOperatorNumeric\(slotId: number\): Promise<string\>
...
@@ -271,7 +271,7 @@ getSimOperatorNumeric\(slotId: number\): Promise<string\>
**示例:**
**示例:**
```
```
js
let
promise
=
sim
.
getSimOperatorNumeric
(
0
);
let
promise
=
sim
.
getSimOperatorNumeric
(
0
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`getSimOperatorNumeric success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`getSimOperatorNumeric success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -298,7 +298,7 @@ getSimSpn\(slotId: number, callback: AsyncCallback<string\>\): void
...
@@ -298,7 +298,7 @@ getSimSpn\(slotId: number, callback: AsyncCallback<string\>\): void
**示例:**
**示例:**
```
```
js
sim
.
getSimSpn
(
0
,
(
err
,
data
)
=>
{
sim
.
getSimSpn
(
0
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -327,7 +327,7 @@ getSimSpn\(slotId: number\): Promise<string\>
...
@@ -327,7 +327,7 @@ getSimSpn\(slotId: number\): Promise<string\>
**示例:**
**示例:**
```
```
js
let
promise
=
sim
.
getSimSpn
(
0
);
let
promise
=
sim
.
getSimSpn
(
0
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`getSimSpn success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`getSimSpn success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -354,7 +354,7 @@ getSimState\(slotId: number, callback: AsyncCallback<SimState\>\): void
...
@@ -354,7 +354,7 @@ getSimState\(slotId: number, callback: AsyncCallback<SimState\>\): void
**示例:**
**示例:**
```
```
js
sim
.
getSimState
(
0
,
(
err
,
data
)
=>
{
sim
.
getSimState
(
0
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -383,7 +383,7 @@ getSimState\(slotId: number\): Promise<SimState\>
...
@@ -383,7 +383,7 @@ getSimState\(slotId: number\): Promise<SimState\>
**示例:**
**示例:**
```
```
js
let
promise
=
sim
.
getSimState
(
0
);
let
promise
=
sim
.
getSimState
(
0
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`getSimState success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`getSimState success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -409,7 +409,7 @@ getCardType\(slotId: number, callback: AsyncCallback<CardType\>\): void
...
@@ -409,7 +409,7 @@ getCardType\(slotId: number, callback: AsyncCallback<CardType\>\): void
**示例:**
**示例:**
```
```
js
sim
.
getCardType
(
0
,
(
err
,
data
)
=>
{
sim
.
getCardType
(
0
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -438,7 +438,7 @@ getCardType\(slotId: number\): Promise<CardType\>
...
@@ -438,7 +438,7 @@ getCardType\(slotId: number\): Promise<CardType\>
**示例:**
**示例:**
```
```
js
let
promise
=
sim
.
getCardType
(
0
);
let
promise
=
sim
.
getCardType
(
0
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`getCardType success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`getCardType success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -465,7 +465,7 @@ hasSimCard\(slotId: number, callback: AsyncCallback<boolean\>\): void
...
@@ -465,7 +465,7 @@ hasSimCard\(slotId: number, callback: AsyncCallback<boolean\>\): void
**示例:**
**示例:**
```
```
jsjs
sim.hasSimCard(0, (err, data) => {
sim.hasSimCard(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
});
...
@@ -494,7 +494,7 @@ hasSimCard\(slotId: number\): Promise<boolean\>
...
@@ -494,7 +494,7 @@ hasSimCard\(slotId: number\): Promise<boolean\>
**示例:**
**示例:**
```
```
js
let
promise
=
sim
.
hasSimCard
(
0
);
let
promise
=
sim
.
hasSimCard
(
0
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`hasSimCard success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`hasSimCard success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -520,7 +520,7 @@ getMaxSimCount\(\): number
...
@@ -520,7 +520,7 @@ getMaxSimCount\(\): number
**示例:**
**示例:**
```
```
js
console
.
log
(
sim
.
getMaxSimCount
())
console
.
log
(
sim
.
getMaxSimCount
())
```
```
...
...
zh-cn/application-dev/reference/apis/js-apis-sms.md
浏览文件 @
6acf3db4
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
## 导入模块
## 导入模块
```
```
js
import
sms
from
'
@ohos.telephony.sms
'
;
import
sms
from
'
@ohos.telephony.sms
'
;
```
```
...
@@ -28,7 +28,7 @@ createMessage\(pdu: Array<number\>, specification: string, callback: AsyncCallba
...
@@ -28,7 +28,7 @@ createMessage\(pdu: Array<number\>, specification: string, callback: AsyncCallba
**示例:**
**示例:**
```
```
js
const
specification
=
'
3gpp
'
;
const
specification
=
'
3gpp
'
;
// 以数组的形式显示协议数据单元(PDU),类型为number,例如[0x08, 0x91, ...]
// 以数组的形式显示协议数据单元(PDU),类型为number,例如[0x08, 0x91, ...]
const
pdu
=
[
0x08
,
0x91
];
const
pdu
=
[
0x08
,
0x91
];
...
@@ -61,7 +61,7 @@ createMessage\(pdu: Array<number\>, specification: string\): Promise<ShortMessag
...
@@ -61,7 +61,7 @@ createMessage\(pdu: Array<number\>, specification: string\): Promise<ShortMessag
**示例:**
**示例:**
```
```
js
const
specification
=
'
3gpp
'
;
const
specification
=
'
3gpp
'
;
// 以数组的形式显示协议数据单元(PDU),类型为number,例如[0x08, 0x91, ...]
// 以数组的形式显示协议数据单元(PDU),类型为number,例如[0x08, 0x91, ...]
const
pdu
=
[
0x08
,
0x91
];
const
pdu
=
[
0x08
,
0x91
];
...
@@ -91,7 +91,7 @@ sendMessage(options: SendMessageOptions): void
...
@@ -91,7 +91,7 @@ sendMessage(options: SendMessageOptions): void
**示例:**
**示例:**
```
```
js
let
sendCallback
=
function
(
err
,
data
)
{
let
sendCallback
=
function
(
err
,
data
)
{
console
.
log
(
`sendCallback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`sendCallback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
}
}
...
@@ -124,7 +124,7 @@ getDefaultSmsSlotId\(callback: AsyncCallback<number\>\): void
...
@@ -124,7 +124,7 @@ getDefaultSmsSlotId\(callback: AsyncCallback<number\>\): void
**示例:**
**示例:**
```
```
js
sms
.
getDefaultSmsSlotId
((
err
,
data
)
=>
{
sms
.
getDefaultSmsSlotId
((
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -147,7 +147,7 @@ getDefaultSmsSlotId\(\): Promise<number\>
...
@@ -147,7 +147,7 @@ getDefaultSmsSlotId\(\): Promise<number\>
**示例:**
**示例:**
```
```
js
let
promise
=
sms
.
getDefaultSmsSlotId
();
let
promise
=
sms
.
getDefaultSmsSlotId
();
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
console
.
log
(
`getDefaultSmsSlotId success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`getDefaultSmsSlotId success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -179,7 +179,7 @@ setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback<void\>\):
...
@@ -179,7 +179,7 @@ setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback<void\>\):
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
let
smscAddr
=
'
+861xxxxxxxxxx
'
;
let
smscAddr
=
'
+861xxxxxxxxxx
'
;
sms
.
setSmscAddr
(
slotId
,
smscAddr
,
(
err
,
data
)
=>
{
sms
.
setSmscAddr
(
slotId
,
smscAddr
,
(
err
,
data
)
=>
{
...
@@ -215,7 +215,7 @@ setSmscAddr\(slotId: number, smscAddr: string\): Promise<void\>
...
@@ -215,7 +215,7 @@ setSmscAddr\(slotId: number, smscAddr: string\): Promise<void\>
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
let
smscAddr
=
'
+861xxxxxxxxxx
'
;
let
smscAddr
=
'
+861xxxxxxxxxx
'
;
let
promise
=
sms
.
setSmscAddr
(
slotId
,
smscAddr
);
let
promise
=
sms
.
setSmscAddr
(
slotId
,
smscAddr
);
...
@@ -248,7 +248,7 @@ getSmscAddr\(slotId: number, callback: AsyncCallback<string\>\): void
...
@@ -248,7 +248,7 @@ getSmscAddr\(slotId: number, callback: AsyncCallback<string\>\): void
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
sms
.
getSmscAddr
(
slotId
,
(
err
,
data
)
=>
{
sms
.
getSmscAddr
(
slotId
,
(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -282,7 +282,7 @@ getSmscAddr\(slotId: number\): Promise<string\>
...
@@ -282,7 +282,7 @@ getSmscAddr\(slotId: number\): Promise<string\>
**示例:**
**示例:**
```
```
js
let
slotId
=
0
;
let
slotId
=
0
;
let
promise
=
sms
.
getSmscAddr
(
slotId
);
let
promise
=
sms
.
getSmscAddr
(
slotId
);
promise
.
then
(
data
=>
{
promise
.
then
(
data
=>
{
...
@@ -306,7 +306,7 @@ hasSmsCapability(): boolean
...
@@ -306,7 +306,7 @@ hasSmsCapability(): boolean
| ------- | ------------------------------------------------------------ |
| ------- | ------------------------------------------------------------ |
| boolean | - true:设备具备短信发送和接收能力
<br/>
- false:设备不具备短信发送和接收能力 |
| boolean | - true:设备具备短信发送和接收能力
<br/>
- false:设备不具备短信发送和接收能力 |
```
```
js
let
result
=
sms
.
hasSmsCapability
();
let
result
=
sms
.
hasSmsCapability
();
console
.
log
(
`hasSmsCapability:
${
JSON
.
stringify
(
result
)}
`
);
console
.
log
(
`hasSmsCapability:
${
JSON
.
stringify
(
result
)}
`
);
```
```
...
...
zh-cn/application-dev/reference/apis/js-apis-socket.md
浏览文件 @
6acf3db4
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
## 导入模块
## 导入模块
```
```
js
import
socket
from
'
@ohos.net.socket
'
;
import
socket
from
'
@ohos.net.socket
'
;
```
```
...
@@ -28,7 +28,7 @@ constructUDPSocketInstance\(\): UDPSocket
...
@@ -28,7 +28,7 @@ constructUDPSocketInstance\(\): UDPSocket
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
```
```
...
@@ -56,7 +56,7 @@ bind\(address: NetAddress, callback: AsyncCallback<void\>\): void
...
@@ -56,7 +56,7 @@ bind\(address: NetAddress, callback: AsyncCallback<void\>\): void
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
udp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
},
err
=>
{
udp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
},
err
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -93,7 +93,7 @@ bind\(address: NetAddress\): Promise<void\>
...
@@ -93,7 +93,7 @@ bind\(address: NetAddress\): Promise<void\>
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
let
promise
=
udp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
8080
,
family
:
1
});
let
promise
=
udp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
8080
,
family
:
1
});
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -123,7 +123,7 @@ send\(options: UDPSendOptions, callback: AsyncCallback<void\>\): void
...
@@ -123,7 +123,7 @@ send\(options: UDPSendOptions, callback: AsyncCallback<void\>\): void
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
udp
.
send
({
udp
.
send
({
data
:
'
Hello, server!
'
,
data
:
'
Hello, server!
'
,
...
@@ -166,7 +166,7 @@ send\(options: UDPSendOptions\): Promise<void\>
...
@@ -166,7 +166,7 @@ send\(options: UDPSendOptions\): Promise<void\>
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
let
promise
=
udp
.
send
({
let
promise
=
udp
.
send
({
data
:
'
Hello, server!
'
,
data
:
'
Hello, server!
'
,
...
@@ -202,7 +202,7 @@ close\(callback: AsyncCallback<void\>\): void
...
@@ -202,7 +202,7 @@ close\(callback: AsyncCallback<void\>\): void
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
udp
.
close
(
err
=>
{
udp
.
close
(
err
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -232,7 +232,7 @@ close\(\): Promise<void\>
...
@@ -232,7 +232,7 @@ close\(\): Promise<void\>
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
let
promise
=
udp
.
close
();
let
promise
=
udp
.
close
();
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -264,7 +264,7 @@ getState\(callback: AsyncCallback<SocketStateBase\>\): void
...
@@ -264,7 +264,7 @@ getState\(callback: AsyncCallback<SocketStateBase\>\): void
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
udp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
},
err
=>
{
udp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
},
err
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -304,7 +304,7 @@ getState\(\): Promise<SocketStateBase\>
...
@@ -304,7 +304,7 @@ getState\(\): Promise<SocketStateBase\>
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
udp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
},
err
=>
{
udp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
},
err
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -345,7 +345,7 @@ setExtraOptions\(options: UDPExtraOptions, callback: AsyncCallback<void\>\): voi
...
@@ -345,7 +345,7 @@ setExtraOptions\(options: UDPExtraOptions, callback: AsyncCallback<void\>\): voi
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
udp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
},
err
=>
{
udp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
},
err
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -397,7 +397,7 @@ setExtraOptions\(options: UDPExtraOptions\): Promise<void\>
...
@@ -397,7 +397,7 @@ setExtraOptions\(options: UDPExtraOptions\): Promise<void\>
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
let
promise
=
udp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
});
let
promise
=
udp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
});
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -437,7 +437,7 @@ on\(type: 'message', callback: Callback<\{message: ArrayBuffer, remoteInfo: Sock
...
@@ -437,7 +437,7 @@ on\(type: 'message', callback: Callback<\{message: ArrayBuffer, remoteInfo: Sock
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
udp
.
on
(
'
message
'
,
value
=>
{
udp
.
on
(
'
message
'
,
value
=>
{
console
.
log
(
"
on message, message:
"
+
value
.
message
+
"
, remoteInfo:
"
+
value
.
remoteInfo
);
console
.
log
(
"
on message, message:
"
+
value
.
message
+
"
, remoteInfo:
"
+
value
.
remoteInfo
);
...
@@ -465,7 +465,7 @@ off\(type: 'message', callback?: Callback<\{message: ArrayBuffer, remoteInfo: So
...
@@ -465,7 +465,7 @@ off\(type: 'message', callback?: Callback<\{message: ArrayBuffer, remoteInfo: So
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
let
callback
=
value
=>
{
let
callback
=
value
=>
{
console
.
log
(
"
on message, message:
"
+
value
.
message
+
"
, remoteInfo:
"
+
value
.
remoteInfo
);
console
.
log
(
"
on message, message:
"
+
value
.
message
+
"
, remoteInfo:
"
+
value
.
remoteInfo
);
...
@@ -494,7 +494,7 @@ on\(type: 'listening' | 'close', callback: Callback<void\>\): void
...
@@ -494,7 +494,7 @@ on\(type: 'listening' | 'close', callback: Callback<void\>\): void
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
udp
.
on
(
'
listening
'
,
()
=>
{
udp
.
on
(
'
listening
'
,
()
=>
{
console
.
log
(
"
on listening success
"
);
console
.
log
(
"
on listening success
"
);
...
@@ -525,7 +525,7 @@ off\(type: 'listening' | 'close', callback?: Callback<void\>\): void
...
@@ -525,7 +525,7 @@ off\(type: 'listening' | 'close', callback?: Callback<void\>\): void
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
let
callback1
=
()
=>
{
let
callback1
=
()
=>
{
console
.
log
(
"
on listening, success
"
);
console
.
log
(
"
on listening, success
"
);
...
@@ -562,7 +562,7 @@ on\(type: 'error', callback: ErrorCallback\): void
...
@@ -562,7 +562,7 @@ on\(type: 'error', callback: ErrorCallback\): void
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
udp
.
on
(
'
error
'
,
err
=>
{
udp
.
on
(
'
error
'
,
err
=>
{
console
.
log
(
"
on error, err:
"
+
JSON
.
stringify
(
err
))
console
.
log
(
"
on error, err:
"
+
JSON
.
stringify
(
err
))
...
@@ -590,7 +590,7 @@ off\(type: 'error', callback?: ErrorCallback\): void
...
@@ -590,7 +590,7 @@ off\(type: 'error', callback?: ErrorCallback\): void
**示例:**
**示例:**
```
```
js
let
udp
=
socket
.
constructUDPSocketInstance
();
let
udp
=
socket
.
constructUDPSocketInstance
();
let
callback
=
err
=>
{
let
callback
=
err
=>
{
console
.
log
(
"
on error, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
"
on error, err:
"
+
JSON
.
stringify
(
err
));
...
@@ -680,7 +680,7 @@ constructTCPSocketInstance\(\): TCPSocket
...
@@ -680,7 +680,7 @@ constructTCPSocketInstance\(\): TCPSocket
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
```
```
...
@@ -709,7 +709,7 @@ bind\(address: NetAddress, callback: AsyncCallback<void\>\): void
...
@@ -709,7 +709,7 @@ bind\(address: NetAddress, callback: AsyncCallback<void\>\): void
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
tcp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
},
err
=>
{
tcp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
},
err
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -745,7 +745,7 @@ bind\(address: NetAddress\): Promise<void\>
...
@@ -745,7 +745,7 @@ bind\(address: NetAddress\): Promise<void\>
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
promise
=
tcp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
});
let
promise
=
tcp
.
bind
({
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
});
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -775,7 +775,7 @@ connect\(options: TCPConnectOptions, callback: AsyncCallback<void\>\): void
...
@@ -775,7 +775,7 @@ connect\(options: TCPConnectOptions, callback: AsyncCallback<void\>\): void
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
},
err
=>
{
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
},
err
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -811,7 +811,7 @@ connect\(options: TCPConnectOptions\): Promise<void\>
...
@@ -811,7 +811,7 @@ connect\(options: TCPConnectOptions\): Promise<void\>
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -844,7 +844,7 @@ send\(options: TCPSendOptions, callback: AsyncCallback<void\>\): void
...
@@ -844,7 +844,7 @@ send\(options: TCPSendOptions, callback: AsyncCallback<void\>\): void
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -891,7 +891,7 @@ send\(options: TCPSendOptions\): Promise<void\>
...
@@ -891,7 +891,7 @@ send\(options: TCPSendOptions\): Promise<void\>
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
promise1
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
let
promise1
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
promise1
.
then
(()
=>
{
promise1
.
then
(()
=>
{
...
@@ -929,7 +929,7 @@ close\(callback: AsyncCallback<void\>\): void
...
@@ -929,7 +929,7 @@ close\(callback: AsyncCallback<void\>\): void
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
tcp
.
close
(
err
=>
{
tcp
.
close
(
err
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -959,7 +959,7 @@ close\(\): Promise<void\>
...
@@ -959,7 +959,7 @@ close\(\): Promise<void\>
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
promise
=
tcp
.
close
();
let
promise
=
tcp
.
close
();
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -991,7 +991,7 @@ getRemoteAddress\(callback: AsyncCallback<NetAddress\>\): void
...
@@ -991,7 +991,7 @@ getRemoteAddress\(callback: AsyncCallback<NetAddress\>\): void
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -1030,7 +1030,7 @@ getRemoteAddress\(\): Promise<NetAddress\>
...
@@ -1030,7 +1030,7 @@ getRemoteAddress\(\): Promise<NetAddress\>
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
promise1
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
let
promise1
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
promise1
.
then
(()
=>
{
promise1
.
then
(()
=>
{
...
@@ -1069,7 +1069,7 @@ getState\(callback: AsyncCallback<SocketStateBase\>\): void
...
@@ -1069,7 +1069,7 @@ getState\(callback: AsyncCallback<SocketStateBase\>\): void
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -1109,7 +1109,7 @@ getState\(\): Promise<SocketStateBase\>
...
@@ -1109,7 +1109,7 @@ getState\(\): Promise<SocketStateBase\>
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -1148,7 +1148,7 @@ setExtraOptions\(options: TCPExtraOptions, callback: AsyncCallback<void\>\): voi
...
@@ -1148,7 +1148,7 @@ setExtraOptions\(options: TCPExtraOptions, callback: AsyncCallback<void\>\): voi
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -1203,7 +1203,7 @@ setExtraOptions\(options: TCPExtraOptions\): Promise<void\>
...
@@ -1203,7 +1203,7 @@ setExtraOptions\(options: TCPExtraOptions\): Promise<void\>
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
let
promise
=
tcp
.
connect
({
address
:
{
address
:
'
192.168.xx.xxx
'
,
port
:
xxxx
,
family
:
1
}
,
timeout
:
6000
});
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -1246,7 +1246,7 @@ on\(type: 'message', callback: Callback<\{message: ArrayBuffer, remoteInfo: Sock
...
@@ -1246,7 +1246,7 @@ on\(type: 'message', callback: Callback<\{message: ArrayBuffer, remoteInfo: Sock
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
tcp
.
on
(
'
message
'
,
value
=>
{
tcp
.
on
(
'
message
'
,
value
=>
{
console
.
log
(
"
on message, message:
"
+
value
.
message
+
"
, remoteInfo:
"
+
value
.
remoteInfo
)
console
.
log
(
"
on message, message:
"
+
value
.
message
+
"
, remoteInfo:
"
+
value
.
remoteInfo
)
...
@@ -1274,7 +1274,7 @@ off\(type: 'message', callback?: Callback<\{message: ArrayBuffer, remoteInfo: So
...
@@ -1274,7 +1274,7 @@ off\(type: 'message', callback?: Callback<\{message: ArrayBuffer, remoteInfo: So
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
callback
=
value
=>
{
let
callback
=
value
=>
{
console
.
log
(
"
on message, message:
"
+
value
.
message
+
"
, remoteInfo:
"
+
value
.
remoteInfo
);
console
.
log
(
"
on message, message:
"
+
value
.
message
+
"
, remoteInfo:
"
+
value
.
remoteInfo
);
...
@@ -1304,7 +1304,7 @@ on\(type: 'connect' | 'close', callback: Callback<void\>\): void
...
@@ -1304,7 +1304,7 @@ on\(type: 'connect' | 'close', callback: Callback<void\>\): void
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
tcp
.
on
(
'
connect
'
,
()
=>
{
tcp
.
on
(
'
connect
'
,
()
=>
{
console
.
log
(
"
on connect success
"
)
console
.
log
(
"
on connect success
"
)
...
@@ -1335,7 +1335,7 @@ off\(type: 'connect' | 'close', callback?: Callback<void\>\): void
...
@@ -1335,7 +1335,7 @@ off\(type: 'connect' | 'close', callback?: Callback<void\>\): void
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
callback1
=
()
=>
{
let
callback1
=
()
=>
{
console
.
log
(
"
on connect success
"
);
console
.
log
(
"
on connect success
"
);
...
@@ -1371,7 +1371,7 @@ on\(type: 'error', callback: ErrorCallback\): void
...
@@ -1371,7 +1371,7 @@ on\(type: 'error', callback: ErrorCallback\): void
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
tcp
.
on
(
'
error
'
,
err
=>
{
tcp
.
on
(
'
error
'
,
err
=>
{
console
.
log
(
"
on error, err:
"
+
JSON
.
stringify
(
err
))
console
.
log
(
"
on error, err:
"
+
JSON
.
stringify
(
err
))
...
@@ -1399,7 +1399,7 @@ off\(type: 'error', callback?: ErrorCallback\): void
...
@@ -1399,7 +1399,7 @@ off\(type: 'error', callback?: ErrorCallback\): void
**示例:**
**示例:**
```
```
js
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
callback
=
err
=>
{
let
callback
=
err
=>
{
console
.
log
(
"
on error, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
"
on error, err:
"
+
JSON
.
stringify
(
err
));
...
...
zh-cn/application-dev/reference/apis/js-apis-system-cipher.md
浏览文件 @
6acf3db4
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
## 导入模块
## 导入模块
```
```
js
import
cipher
from
'
@system.cipher
'
import
cipher
from
'
@system.cipher
'
```
```
...
@@ -36,7 +36,7 @@ RSA 算法加解密。
...
@@ -36,7 +36,7 @@ RSA 算法加解密。
**示例:**
**示例:**
```
```
js
export
default
{
export
default
{
rsa
()
{
rsa
()
{
cipher
.
rsa
({
cipher
.
rsa
({
...
@@ -118,7 +118,7 @@ AES 算法加解密。
...
@@ -118,7 +118,7 @@ AES 算法加解密。
**示例:**
**示例:**
```
```
js
export
default
{
export
default
{
aes
()
{
aes
()
{
cipher
.
aes
({
cipher
.
aes
({
...
...
zh-cn/application-dev/reference/apis/js-apis-telephony-data.md
浏览文件 @
6acf3db4
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
## 导入模块
## 导入模块
```
```
js
import
data
from
'
@ohos.telephony.data
'
;
import
data
from
'
@ohos.telephony.data
'
;
```
```
...
@@ -28,7 +28,7 @@ getDefaultCellularDataSlotId(callback: AsyncCallback\<number\>): void
...
@@ -28,7 +28,7 @@ getDefaultCellularDataSlotId(callback: AsyncCallback\<number\>): void
**示例:**
**示例:**
```
```
js
data
.
getDefaultCellularDataSlotId
((
err
,
data
)
=>
{
data
.
getDefaultCellularDataSlotId
((
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -52,7 +52,7 @@ getDefaultCellularDataSlotId(): Promise\<number\>
...
@@ -52,7 +52,7 @@ getDefaultCellularDataSlotId(): Promise\<number\>
**示例:**
**示例:**
```
```
js
let
promise
=
data
.
getDefaultCellularDataSlotId
();
let
promise
=
data
.
getDefaultCellularDataSlotId
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
log
(
`test success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`test success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -77,7 +77,7 @@ getCellularDataFlowType(callback: AsyncCallback\<DataFlowType\>): void
...
@@ -77,7 +77,7 @@ getCellularDataFlowType(callback: AsyncCallback\<DataFlowType\>): void
**示例:**
**示例:**
```
```
js
data
.
getCellularDataFlowType
((
err
,
data
)
=>
{
data
.
getCellularDataFlowType
((
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -99,7 +99,7 @@ getCellularDataFlowType(): Promise\<DataFlowType\>
...
@@ -99,7 +99,7 @@ getCellularDataFlowType(): Promise\<DataFlowType\>
**示例:**
**示例:**
```
```
js
let
promise
=
data
.
getCellularDataFlowType
();
let
promise
=
data
.
getCellularDataFlowType
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
log
(
`test success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`test success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -124,7 +124,7 @@ getCellularDataState(callback: AsyncCallback\<DataConnectState\>): void
...
@@ -124,7 +124,7 @@ getCellularDataState(callback: AsyncCallback\<DataConnectState\>): void
**示例:**
**示例:**
```
```
js
data
.
getCellularDataState
((
err
,
data
)
=>
{
data
.
getCellularDataState
((
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -146,7 +146,7 @@ getCellularDataState(): Promise\<DataConnectState\>
...
@@ -146,7 +146,7 @@ getCellularDataState(): Promise\<DataConnectState\>
**示例:**
**示例:**
```
```
js
let
promise
=
data
.
getCellularDataState
();
let
promise
=
data
.
getCellularDataState
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
log
(
`test success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`test success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -173,7 +173,7 @@ isCellularDataEnabled(callback: AsyncCallback\<boolean\>): void
...
@@ -173,7 +173,7 @@ isCellularDataEnabled(callback: AsyncCallback\<boolean\>): void
**示例:**
**示例:**
```
```
js
data
.
isCellularDataEnabled
((
err
,
data
)
=>
{
data
.
isCellularDataEnabled
((
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -197,7 +197,7 @@ isCellularDataEnabled(): Promise\<boolean\>
...
@@ -197,7 +197,7 @@ isCellularDataEnabled(): Promise\<boolean\>
**示例:**
**示例:**
```
```
js
let
promise
=
data
.
isCellularDataEnabled
();
let
promise
=
data
.
isCellularDataEnabled
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
log
(
`test success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`test success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
@@ -225,7 +225,7 @@ isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\<boolean\>)
...
@@ -225,7 +225,7 @@ isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\<boolean\>)
**示例:**
**示例:**
```
```
js
data
.
isCellularDataRoamingEnabled
(
0
,(
err
,
data
)
=>
{
data
.
isCellularDataRoamingEnabled
(
0
,(
err
,
data
)
=>
{
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`callback: err->
${
JSON
.
stringify
(
err
)}
, data->
${
JSON
.
stringify
(
data
)}
`
);
});
});
...
@@ -255,7 +255,7 @@ isCellularDataRoamingEnabled(slotId: number): Promise\<boolean\>
...
@@ -255,7 +255,7 @@ isCellularDataRoamingEnabled(slotId: number): Promise\<boolean\>
**示例:**
**示例:**
```
```
js
let
promise
=
data
.
isCellularDataRoamingEnabled
(
0
);
let
promise
=
data
.
isCellularDataRoamingEnabled
(
0
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
log
(
`test success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`test success, promise: data->
${
JSON
.
stringify
(
data
)}
`
);
...
...
zh-cn/application-dev/reference/apis/js-apis-webSocket.md
浏览文件 @
6acf3db4
...
@@ -12,13 +12,13 @@
...
@@ -12,13 +12,13 @@
## 导入模块
## 导入模块
```
```
js
import
webSocket
from
'
@ohos.net.webSocket
'
;
import
webSocket
from
'
@ohos.net.webSocket
'
;
```
```
## 完整示例
## 完整示例
```
```
js
import
webSocket
from
'
@ohos.net.webSocket
'
;
import
webSocket
from
'
@ohos.net.webSocket
'
;
var
defaultIpAddress
=
"
ws://
"
;
var
defaultIpAddress
=
"
ws://
"
;
...
@@ -78,7 +78,7 @@ createWebSocket\(\): WebSocket
...
@@ -78,7 +78,7 @@ createWebSocket\(\): WebSocket
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
```
```
...
@@ -107,7 +107,7 @@ connect\(url: string, callback: AsyncCallback<boolean\>\): void
...
@@ -107,7 +107,7 @@ connect\(url: string, callback: AsyncCallback<boolean\>\): void
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
let
url
=
"
ws://
"
let
url
=
"
ws://
"
ws
.
connect
(
url
,
(
err
,
value
)
=>
{
ws
.
connect
(
url
,
(
err
,
value
)
=>
{
...
@@ -141,7 +141,7 @@ connect\(url: string, options: WebSocketRequestOptions, callback: AsyncCallback<
...
@@ -141,7 +141,7 @@ connect\(url: string, options: WebSocketRequestOptions, callback: AsyncCallback<
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
let
url
=
"
ws://
"
let
url
=
"
ws://
"
ws
.
connect
(
url
,
{
ws
.
connect
(
url
,
{
...
@@ -184,7 +184,7 @@ connect\(url: string, options?: WebSocketRequestOptions\): Promise<boolean\>
...
@@ -184,7 +184,7 @@ connect\(url: string, options?: WebSocketRequestOptions\): Promise<boolean\>
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
let
url
=
"
ws://
"
let
url
=
"
ws://
"
let
promise
=
ws
.
connect
(
url
);
let
promise
=
ws
.
connect
(
url
);
...
@@ -215,7 +215,7 @@ send\(data: string | ArrayBuffer, callback: AsyncCallback<boolean\>\): void
...
@@ -215,7 +215,7 @@ send\(data: string | ArrayBuffer, callback: AsyncCallback<boolean\>\): void
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
let
url
=
"
ws://
"
let
url
=
"
ws://
"
ws
.
connect
(
url
,
(
err
,
value
)
=>
{
ws
.
connect
(
url
,
(
err
,
value
)
=>
{
...
@@ -254,7 +254,7 @@ send\(data: string | ArrayBuffer\): Promise<boolean\>
...
@@ -254,7 +254,7 @@ send\(data: string | ArrayBuffer\): Promise<boolean\>
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
let
url
=
"
ws://
"
let
url
=
"
ws://
"
ws
.
connect
(
url
,
(
err
,
value
)
=>
{
ws
.
connect
(
url
,
(
err
,
value
)
=>
{
...
@@ -286,7 +286,7 @@ close\(callback: AsyncCallback<boolean\>\): void
...
@@ -286,7 +286,7 @@ close\(callback: AsyncCallback<boolean\>\): void
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
let
url
=
"
ws://
"
let
url
=
"
ws://
"
ws
.
close
((
err
,
value
)
=>
{
ws
.
close
((
err
,
value
)
=>
{
...
@@ -318,7 +318,7 @@ close\(options: WebSocketCloseOptions, callback: AsyncCallback<boolean\>\): void
...
@@ -318,7 +318,7 @@ close\(options: WebSocketCloseOptions, callback: AsyncCallback<boolean\>\): void
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
let
url
=
"
ws://
"
let
url
=
"
ws://
"
ws
.
close
({
ws
.
close
({
...
@@ -358,7 +358,7 @@ close\(options?: WebSocketCloseOptions\): Promise<boolean\>
...
@@ -358,7 +358,7 @@ close\(options?: WebSocketCloseOptions\): Promise<boolean\>
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
let
url
=
"
ws://
"
let
url
=
"
ws://
"
let
promise
=
ws
.
close
({
let
promise
=
ws
.
close
({
...
@@ -391,7 +391,7 @@ on\(type: 'open', callback: AsyncCallback<Object\>\): void
...
@@ -391,7 +391,7 @@ on\(type: 'open', callback: AsyncCallback<Object\>\): void
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
ws
.
on
(
'
open
'
,
(
err
,
value
)
=>
{
ws
.
on
(
'
open
'
,
(
err
,
value
)
=>
{
console
.
log
(
"
on open, status:
"
+
value
.
status
+
"
, message:
"
+
value
.
message
);
console
.
log
(
"
on open, status:
"
+
value
.
status
+
"
, message:
"
+
value
.
message
);
...
@@ -419,7 +419,7 @@ off\(type: 'open', callback?: AsyncCallback<Object\>\): void
...
@@ -419,7 +419,7 @@ off\(type: 'open', callback?: AsyncCallback<Object\>\): void
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
let
callback1
=
(
err
,
value
)
=>
{
let
callback1
=
(
err
,
value
)
=>
{
console
.
log
(
"
on open, status:
"
+
value
.
status
+
"
, message:
"
+
value
.
message
);
console
.
log
(
"
on open, status:
"
+
value
.
status
+
"
, message:
"
+
value
.
message
);
...
@@ -451,7 +451,7 @@ on\(type: 'message', callback: AsyncCallback<string | ArrayBuffer\>\): void
...
@@ -451,7 +451,7 @@ on\(type: 'message', callback: AsyncCallback<string | ArrayBuffer\>\): void
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
ws
.
on
(
'
message
'
,
(
err
,
value
)
=>
{
ws
.
on
(
'
message
'
,
(
err
,
value
)
=>
{
console
.
log
(
"
on message, message:
"
+
value
);
console
.
log
(
"
on message, message:
"
+
value
);
...
@@ -480,7 +480,7 @@ off\(type: 'message', callback?: AsyncCallback<string | ArrayBuffer\>\): void
...
@@ -480,7 +480,7 @@ off\(type: 'message', callback?: AsyncCallback<string | ArrayBuffer\>\): void
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
ws
.
off
(
'
message
'
);
ws
.
off
(
'
message
'
);
```
```
...
@@ -503,7 +503,7 @@ on\(type: 'close', callback: AsyncCallback<\{ code: number, reason: string \}\>\
...
@@ -503,7 +503,7 @@ on\(type: 'close', callback: AsyncCallback<\{ code: number, reason: string \}\>\
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
ws
.
on
(
'
close
'
,
(
err
,
value
)
=>
{
ws
.
on
(
'
close
'
,
(
err
,
value
)
=>
{
console
.
log
(
"
on close, code is
"
+
value
.
code
+
"
, reason is
"
+
value
.
reason
);
console
.
log
(
"
on close, code is
"
+
value
.
code
+
"
, reason is
"
+
value
.
reason
);
...
@@ -532,7 +532,7 @@ off\(type: 'close', callback?: AsyncCallback<\{ code: number, reason: string \}\
...
@@ -532,7 +532,7 @@ off\(type: 'close', callback?: AsyncCallback<\{ code: number, reason: string \}\
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
ws
.
off
(
'
close
'
);
ws
.
off
(
'
close
'
);
```
```
...
@@ -556,7 +556,7 @@ on\(type: 'error', callback: ErrorCallback\): void
...
@@ -556,7 +556,7 @@ on\(type: 'error', callback: ErrorCallback\): void
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
ws
.
on
(
'
error
'
,
(
err
)
=>
{
ws
.
on
(
'
error
'
,
(
err
)
=>
{
console
.
log
(
"
on error, error:
"
+
JSON
.
stringify
(
err
))
console
.
log
(
"
on error, error:
"
+
JSON
.
stringify
(
err
))
...
@@ -584,7 +584,7 @@ off\(type: 'error', callback?: ErrorCallback\): void
...
@@ -584,7 +584,7 @@ off\(type: 'error', callback?: ErrorCallback\): void
**示例:**
**示例:**
```
```
js
let
ws
=
webSocket
.
createWebSocket
();
let
ws
=
webSocket
.
createWebSocket
();
ws
.
off
(
'
error
'
);
ws
.
off
(
'
error
'
);
```
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录