提交 6acf3db4 编写于 作者: Z zengyawen

update docs

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