From 6acf3db455be1c0f85b9c43291255e6796f56893 Mon Sep 17 00:00:00 2001 From: zengyawen Date: Wed, 11 May 2022 12:01:05 +0800 Subject: [PATCH] update docs Signed-off-by: zengyawen --- .../apis/js-apis-abilityAccessCtrl.md | 16 +- .../reference/apis/js-apis-call.md | 36 ++-- .../reference/apis/js-apis-contact.md | 158 +++++++++--------- .../reference/apis/js-apis-convertxml.md | 2 +- .../reference/apis/js-apis-faultLogger.md | 6 +- .../reference/apis/js-apis-http.md | 24 +-- .../reference/apis/js-apis-net-connection.md | 60 +++---- .../reference/apis/js-apis-observer.md | 36 ++-- .../reference/apis/js-apis-radio.md | 38 ++--- .../reference/apis/js-apis-request.md | 22 +-- .../reference/apis/js-apis-sim.md | 40 ++--- .../reference/apis/js-apis-sms.md | 22 +-- .../reference/apis/js-apis-socket.md | 78 ++++----- .../reference/apis/js-apis-system-cipher.md | 6 +- .../reference/apis/js-apis-telephony-data.md | 22 +-- .../reference/apis/js-apis-webSocket.md | 38 ++--- 16 files changed, 302 insertions(+), 302 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 7a29614e76..2b0205042d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -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<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<number&g **示例:** -``` +```js var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; let promise = AtManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); diff --git a/zh-cn/application-dev/reference/apis/js-apis-call.md b/zh-cn/application-dev/reference/apis/js-apis-call.md index 87292d1fb7..18e866d497 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-call.md +++ b/zh-cn/application-dev/reference/apis/js-apis-call.md @@ -30,7 +30,7 @@ dial\(phoneNumber: string, callback: AsyncCallback\): 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 { @@ -91,7 +91,7 @@ dial\(phoneNumber: string, options?: DialOptions\): Promise **示例:** -``` +```js let promise = call.dial("138xxxxxxxx", { extras: false }); @@ -121,7 +121,7 @@ makeCall(phoneNumber: string, callback: AsyncCallback\): void **示例:** -``` +```js call.makeCall("138xxxxxxxx", err => { console.log(`makeCall callback: err->${JSON.stringify(err)}`); }); @@ -152,7 +152,7 @@ makeCall(phoneNumber: string): Promise\ **示例:** -``` +```js let promise = call.makeCall("138xxxxxxxx"); promise.then(() => { console.log(`makeCall success`); @@ -177,7 +177,7 @@ hasCall\(callback: AsyncCallback\): void **示例:** -``` +```js call.hasCall((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -200,7 +200,7 @@ hasCall\(\): Promise **示例:** -``` +```js let promise = call.hasCall(); promise.then(data => { console.log(`hasCall success, promise: data->${JSON.stringify(data)}`); @@ -226,7 +226,7 @@ getCallState\(callback: AsyncCallback\): void **示例:** -``` +```js call.getCallState((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -249,7 +249,7 @@ getCallState\(\): Promise **示例:** -``` +```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:设备具备语音通话能力
- false:设备不具备语音通话能力 | -``` +```js let result = call.hasVoiceCapability(); console.log(`hasVoiceCapability: ${JSON.stringify(result)}`); ``` @@ -294,7 +294,7 @@ isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback\) **示例:** -``` +```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\): 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 { if (err) { console.log(`deleteContact callback: err->${JSON.stringify(err)}`); @@ -129,7 +129,7 @@ deleteContact(key: string): Promise<void> **示例:** - ``` + ```js let promise = contact.deleteContact('xxx'); promise.then(() => { console.log(`deleteContact success`); @@ -157,7 +157,7 @@ updateContact(contact: Contact, callback: AsyncCallback<void>): 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<void> **示例:** - ``` + ```js let promise = contact.updateContact({ fullName: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] @@ -262,7 +262,7 @@ isLocalContact(id: number, callback: AsyncCallback<boolean>): 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<boolean> **示例:** - ``` + ```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<boolean>): 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<boolean> **示例:** - ``` + ```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<Contact>): 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<Contact>): v **示例:** - ``` + ```js contact.queryMyCard({ attributes:['ATTR_EMAIL', 'ATTR_NAME'] }, (err, data) => { @@ -447,7 +447,7 @@ queryMyCard(attrs?: ContactAttributes): Promise<Contact> **示例:** - ``` + ```js let promise = contact.queryMyCard({ attributes:['ATTR_EMAIL', 'ATTR_NAME'] }); @@ -478,7 +478,7 @@ selectContact(callback: AsyncCallback<Array<Contact>>): void **示例:** - ``` + ```js contact.selectContact((err, data) => { if (err) { console.log(`selectContact callback: err->${JSON.stringify(err)}`); @@ -508,7 +508,7 @@ selectContact(): Promise<Array<Contact>> **示例:** - ``` + ```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<Contact>): 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<Contact> **示例:** - ``` + ```js contact.queryContact('xxx', { holderId: 0 }, (err, data) => { @@ -598,7 +598,7 @@ queryContact(key: string, attrs: ContactAttributes, callback: AsyncCallback< **示例:** - ``` + ```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<Array<Contact>>): 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<Array<Contact>> **示例:** - ``` + ```js contact.queryContacts({ holderId: 0 }, (err, data) => { @@ -761,7 +761,7 @@ queryContacts(attrs: ContactAttributes, callback: AsyncCallback<Array<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<Array<C **示例:** - ``` + ```js let promise = contact.queryContacts({ holderId: 0 }, { @@ -863,7 +863,7 @@ queryContactsByPhoneNumber(phoneNumber: string, callback: AsyncCallback<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<Array<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<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<Array<Group>>): 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<Array<Group>>): **示例:** - ``` + ```js contact.queryGroups({ holderId: 0 }, (err, data) => { @@ -1258,7 +1258,7 @@ queryGroups(holder?: Holder): Promise<Array<Group>> **示例:** - ``` + ```js let promise = contact.queryGroups({ holderId: 0 }); @@ -1287,7 +1287,7 @@ queryHolders(callback: AsyncCallback<Array<Holder>>): void **示例:** - ``` + ```js contact.queryHolders((err, data) => { if (err) { console.log(`queryHolders callback: err->${JSON.stringify(err)}`); @@ -1315,7 +1315,7 @@ queryHolders(): Promise<Array<Holder>> **示例:** - ``` + ```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<string>): 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<string>): voi **示例:** - ``` + ```js contact.queryKey(id, { holderId:1 }, (err, data) => { @@ -1409,7 +1409,7 @@ queryKey(id: number, holder?: Holder): Promise<string> **示例:** - ``` + ```js let promise = contact.queryKey(id, { holderId: 0 }); @@ -1462,7 +1462,7 @@ queryKey(id: number, holder?: Holder): Promise<string> 使用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 diff --git a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md index 103ba31edf..8c5d07f459 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md +++ b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md @@ -6,7 +6,7 @@ ## 导入模块 -``` +```js import convertxml from '@ohos.convertxml'; ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md b/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md index a9e68dd3d1..d320c24acf 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md +++ b/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md @@ -4,7 +4,7 @@ ## 导入模块 -``` +```js import faultLogger from '@ohos.faultLogger' ``` @@ -56,7 +56,7 @@ querySelfFaultLog(faultType: FaultType, callback: AsyncCallback<Array<Faul **示例:** -``` +```js function queryFaultLogCallback(error, value) { if (error) { console.info('error is ' + error); @@ -101,7 +101,7 @@ querySelfFaultLog(faultType: FaultType) : Promise<Array<FaultLogInfo>&g **示例:** -``` +```js async function getLog() { let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH); if (value) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-http.md b/zh-cn/application-dev/reference/apis/js-apis-http.md index 93e4238887..2627f771f9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-http.md +++ b/zh-cn/application-dev/reference/apis/js-apis-http.md @@ -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\\):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 **示例:** -``` +```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\): void **示例:** -``` +```js httpRequest.on('headerReceive', (err, data) => { if (!err) { console.info('header: ' + JSON.stringify(data)); @@ -272,7 +272,7 @@ off\(type: 'headerReceive', callback?: AsyncCallback\): void **示例:** -``` +```js httpRequest.off('headerReceive'); ``` @@ -293,7 +293,7 @@ on\(type: 'headersReceive', callback: Callback\): void **示例:** -``` +```js httpRequest.on('headersReceive', (header) => { console.info('header: ' + JSON.stringify(header)); }); @@ -320,7 +320,7 @@ off\(type: 'headersReceive', callback?: Callback\): void **示例:** -``` +```js httpRequest.off('headersReceive'); ``` @@ -341,7 +341,7 @@ once\(type: 'headersReceive', callback: Callback\): void **示例:** -``` +```js httpRequest.once('headersReceive', (header) => { console.info('header: ' + JSON.stringify(header)); }); diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md index d62301a861..15cc2ce900 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md +++ b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md @@ -7,7 +7,7 @@ ## 导入模块 -```javascript +```js import connection from '@ohos.net.connection' ``` @@ -29,7 +29,7 @@ getDefaultNet(callback: AsyncCallback\): void **示例:** -```javascript +```js connection.getDefaultNet(function (error, netHandle) { console.log(JSON.stringify(error)) console.log(JSON.stringify(netHandle)) @@ -54,7 +54,7 @@ getDefaultNet(): Promise\ **示例:** -```javascript +```js connection.getDefaultNet().then(function (netHandle) { console.log(JSON.stringify(netHandle)) }) @@ -76,7 +76,7 @@ hasDefaultNet(callback: AsyncCallback\): void **示例:** -```javascript +```js connection.hasDefaultNet(function (error, has) { console.log(JSON.stringify(error)) console.log(has) @@ -99,7 +99,7 @@ hasDefaultNet(): Promise\ **示例:** -```javascript +```js connection.hasDefaultNet().then(function (has) { console.log(has) }) @@ -122,7 +122,7 @@ getAllNets(callback: AsyncCallback<Array<NetHandle>>): void **示例:** -``` +```js connection.getAllNets(function (error, nets) { console.log(JSON.stringify(error)) console.log(JSON.stringify(nets)) @@ -147,7 +147,7 @@ getAllNets(): Promise<Array<NetHandle>> **示例:** -``` +```js connection.getAllNets().then(function (nets) { console.log(JSON.stringify(nets)) }); @@ -172,7 +172,7 @@ getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\ **示例:** -```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\ **示例:** -```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<void>): 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<void> **示例:** -``` +```js connection.getDefaultNet().then(function (netHandle) { connection.reportNetConnected(netHandle).then(function () { console.log(`report success`) @@ -349,7 +349,7 @@ reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback<void>) **示例:** -``` +```js connection.getDefaultNet().then(function (netHandle) { connection.reportNetDisconnected(netHandle, function (error) { console.log(JSON.stringify(error)) @@ -380,7 +380,7 @@ reportNetDisconnected(netHandle: NetHandle): Promise<void> **示例:** -``` +```js connection.getDefaultNet().then(function (netHandle) { connection.reportNetDisconnected(netHandle).then(function () { console.log(`report success`) @@ -407,7 +407,7 @@ getAddressesByName(host: string, callback: AsyncCallback\>): **示例:** -``` +```js let host = "xxxx"; connection.getAddressesByName(host, function (error, addresses) { console.log(JSON.stringify(error)) @@ -439,7 +439,7 @@ getAddressesByName(host: string): Promise\> **示例:** -``` +```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\): 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<{ netHandle: NetHandle, b **示例:** -```javascript +```js netConnection.on('netBlockStatusChange', function (data) { console.log(JSON.stringify(data)) }) @@ -594,7 +594,7 @@ on(type: 'netLost', callback: Callback\): 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 **示例:** -```javascript +```js netConnection.on('netUnavailable', function (data) { console.log(JSON.stringify(data)) }) @@ -642,7 +642,7 @@ register(callback: AsyncCallback\): void **示例:** -```javascript +```js netConnection.register(function (error) { console.log(JSON.stringify(error)) }) @@ -664,7 +664,7 @@ unregister(callback: AsyncCallback\): void **示例:** -```javascript +```js netConnection.unregister(function (error) { console.log(JSON.stringify(error)) }) @@ -703,7 +703,7 @@ getAddressesByName(host: string, callback: AsyncCallback\>): **示例:** -```javascript +```js connection.getDefaultNet().then(function (netHandle) { let host = "xxxx"; netHandle.getAddressesByName(host, function (error, addresses) { @@ -737,7 +737,7 @@ getAddressesByName(host: string): Promise\> **示例:** -```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\): 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\ **示例:** -```javascript +```js connection.getDefaultNet().then(function (netHandle) { let host = "xxxx"; netHandle.getAddressByName(host).then(function (address) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-observer.md b/zh-cn/application-dev/reference/apis/js-apis-observer.md index 8524606e28..c8ede5b932 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-observer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-observer.md @@ -30,7 +30,7 @@ on\(type: \'networkStateChange\', callback: Callback\): 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\): void; **示例:** -``` +```js let callback = data => { console.log("on networkStateChange, data:" + JSON.stringify(data)); } @@ -114,7 +114,7 @@ on\(type: \'signalInfoChange\', callback: Callback\>): **示例:** -``` +```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\> **示例:** -``` +```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\\): 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\\): void **示例:** -``` +```js let callback = data => { console.log("on cellularDataFlowChange, data:" + JSON.stringify(data)); } @@ -444,7 +444,7 @@ on\(type: 'simStateChange', callback: Callback\\): 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\{ console.log("on simStateChange, data:" + JSON.stringify(data)); }); @@ -497,7 +497,7 @@ off\(type: 'simStateChange', callback?: Callback\\): void; **示例:** -``` +```js let callback = data => { console.log("on simStateChange, data:" + JSON.stringify(data)); } diff --git a/zh-cn/application-dev/reference/apis/js-apis-radio.md b/zh-cn/application-dev/reference/apis/js-apis-radio.md index 471660979b..5bf21f1949 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-radio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-radio.md @@ -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\): 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\): 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 **示例:** -``` +```js let slotId = 0; let promise = radio.getNetworkState(slotId); promise.then(data => { @@ -177,7 +177,7 @@ getNetworkSelectionMode\(slotId: number, callback: AsyncCallback { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -207,7 +207,7 @@ getNetworkSelectionMode\(slotId: number\): Promise **示例:** -``` +```js let slotId = 0; let promise = radio.getNetworkSelectionMode(slotId); promise.then(data => { @@ -235,7 +235,7 @@ getISOCountryCodeForNetwork\(slotId: number, callback: AsyncCallback\): **示例:** -``` +```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 **示例:** -``` +```js let slotId = 0; let promise = radio.getISOCountryCodeForNetwork(slotId); promise.then(data => { @@ -292,7 +292,7 @@ getPrimarySlotId\(callback: AsyncCallback\\): void **示例:** -``` +```js radio.getPrimarySlotId((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -315,7 +315,7 @@ getPrimarySlotId\(\): Promise\ **示例:** -``` +```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 { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -372,7 +372,7 @@ getSignalInformation\(slotId: number\): Promise\> **示例:** -``` +```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\): 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\): 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 **示例:** -``` +```js let slotId = 0; let promise = radio.isRadioOn(slotId); promise.then(data => { @@ -516,7 +516,7 @@ getOperatorName\(slotId: number, callback: AsyncCallback\): 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 **示例:** -``` +```js let slotId = 0; let promise = radio.getOperatorName(slotId); promise.then(data => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index 4be83b781f..66c1f7e336 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -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 } + ... } - ``` + } +``` ## 常量 diff --git a/zh-cn/application-dev/reference/apis/js-apis-sim.md b/zh-cn/application-dev/reference/apis/js-apis-sim.md index df158c3a26..d47e6cb067 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sim.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sim.md @@ -7,7 +7,7 @@ ## 导入模块 -``` +```js import sim from '@ohos.telephony.sim'; ``` @@ -28,7 +28,7 @@ isSimActive\(slotId: number, callback: AsyncCallback\): 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 **示例:** -``` +```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\): void **示例:** -``` +```js sim.getDefaultVoiceSlotId((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -106,7 +106,7 @@ getDefaultVoiceSlotId\(\): Promise **示例:** -``` +```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\): 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 **示例:** -``` +```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\): 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 **示例:** -``` +```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\): 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 **示例:** -``` +```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\): 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 **示例:** -``` +```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\): 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 **示例:** -``` +```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\): 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 **示例:** -``` +```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\): 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 **示例:** -``` +```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()) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-sms.md b/zh-cn/application-dev/reference/apis/js-apis-sms.md index 92251d2663..e776a9365c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sms.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sms.md @@ -6,7 +6,7 @@ ## 导入模块 -``` +```js import sms from '@ohos.telephony.sms'; ``` @@ -28,7 +28,7 @@ createMessage\(pdu: Array, specification: string, callback: AsyncCallba **示例:** -``` +```js const specification = '3gpp'; // 以数组的形式显示协议数据单元(PDU),类型为number,例如[0x08, 0x91, ...] const pdu = [0x08, 0x91]; @@ -61,7 +61,7 @@ createMessage\(pdu: Array, specification: string\): Promise${JSON.stringify(err)}, data->${JSON.stringify(data)}`); } @@ -124,7 +124,7 @@ getDefaultSmsSlotId\(callback: AsyncCallback\): void **示例:** -``` +```js sms.getDefaultSmsSlotId((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -147,7 +147,7 @@ getDefaultSmsSlotId\(\): Promise **示例:** -``` +```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\): **示例:** -``` +```js let slotId = 0; let smscAddr = '+861xxxxxxxxxx'; sms.setSmscAddr(slotId, smscAddr, (err,data) => { @@ -215,7 +215,7 @@ setSmscAddr\(slotId: number, smscAddr: string\): Promise **示例:** -``` +```js let slotId = 0; let smscAddr = '+861xxxxxxxxxx'; let promise = sms.setSmscAddr(slotId, smscAddr); @@ -248,7 +248,7 @@ getSmscAddr\(slotId: number, callback: AsyncCallback\): 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 **示例:** -``` +```js let slotId = 0; let promise = sms.getSmscAddr(slotId); promise.then(data => { @@ -306,7 +306,7 @@ hasSmsCapability(): boolean | ------- | ------------------------------------------------------------ | | boolean | - true:设备具备短信发送和接收能力
- false:设备不具备短信发送和接收能力 | -``` +```js let result = sms.hasSmsCapability(); console.log(`hasSmsCapability: ${JSON.stringify(result)}`); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-socket.md b/zh-cn/application-dev/reference/apis/js-apis-socket.md index 91bbb30576..0b570cefdd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-socket.md +++ b/zh-cn/application-dev/reference/apis/js-apis-socket.md @@ -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 **示例:** -``` +```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 **示例:** -``` +```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 **示例:** -``` +```js let udp = socket.constructUDPSocketInstance(); udp.send({ data:'Hello, server!', @@ -166,7 +166,7 @@ send\(options: UDPSendOptions\): Promise **示例:** -``` +```js let udp = socket.constructUDPSocketInstance(); let promise = udp.send({ data:'Hello, server!', @@ -202,7 +202,7 @@ close\(callback: AsyncCallback\): void **示例:** -``` +```js let udp = socket.constructUDPSocketInstance(); udp.close(err => { if (err) { @@ -232,7 +232,7 @@ close\(\): Promise **示例:** -``` +```js let udp = socket.constructUDPSocketInstance(); let promise = udp.close(); promise.then(() => { @@ -264,7 +264,7 @@ getState\(callback: AsyncCallback\): 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 **示例:** -``` +```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\): 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 **示例:** -``` +```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 **示例:** -``` +```js let udp = socket.constructUDPSocketInstance(); udp.on('listening', () => { console.log("on listening success"); @@ -525,7 +525,7 @@ off\(type: 'listening' | 'close', callback?: Callback\): 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 **示例:** -``` +```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 **示例:** -``` +```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 **示例:** -``` +```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 **示例:** -``` +```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 **示例:** -``` +```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 **示例:** -``` +```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 **示例:** -``` +```js let tcp = socket.constructTCPSocketInstance(); tcp.close(err => { if (err) { @@ -959,7 +959,7 @@ close\(\): Promise **示例:** -``` +```js let tcp = socket.constructTCPSocketInstance(); let promise = tcp.close(); promise.then(() => { @@ -991,7 +991,7 @@ getRemoteAddress\(callback: AsyncCallback\): 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 **示例:** -``` +```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\): 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 **示例:** -``` +```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\): 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 **示例:** -``` +```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 **示例:** -``` +```js let tcp = socket.constructTCPSocketInstance(); tcp.on('connect', () => { console.log("on connect success") @@ -1335,7 +1335,7 @@ off\(type: 'connect' | 'close', callback?: Callback\): 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)); diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-cipher.md b/zh-cn/application-dev/reference/apis/js-apis-system-cipher.md index dd1b1d13f7..3cabf0c468 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-cipher.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-cipher.md @@ -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({ diff --git a/zh-cn/application-dev/reference/apis/js-apis-telephony-data.md b/zh-cn/application-dev/reference/apis/js-apis-telephony-data.md index e819cbdc49..87d7295989 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-telephony-data.md +++ b/zh-cn/application-dev/reference/apis/js-apis-telephony-data.md @@ -6,7 +6,7 @@ ## 导入模块 -``` +```js import data from '@ohos.telephony.data'; ``` @@ -28,7 +28,7 @@ getDefaultCellularDataSlotId(callback: AsyncCallback\): void **示例:** -``` +```js data.getDefaultCellularDataSlotId((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -52,7 +52,7 @@ getDefaultCellularDataSlotId(): Promise\ **示例:** -``` +```js let promise = data.getDefaultCellularDataSlotId(); promise.then((data) => { console.log(`test success, promise: data->${JSON.stringify(data)}`); @@ -77,7 +77,7 @@ getCellularDataFlowType(callback: AsyncCallback\): void **示例:** -``` +```js data.getCellularDataFlowType((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -99,7 +99,7 @@ getCellularDataFlowType(): Promise\ **示例:** -``` +```js let promise = data.getCellularDataFlowType(); promise.then((data) => { console.log(`test success, promise: data->${JSON.stringify(data)}`); @@ -124,7 +124,7 @@ getCellularDataState(callback: AsyncCallback\): void **示例:** -``` +```js data.getCellularDataState((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -146,7 +146,7 @@ getCellularDataState(): Promise\ **示例:** -``` +```js let promise = data.getCellularDataState(); promise.then((data) => { console.log(`test success, promise: data->${JSON.stringify(data)}`); @@ -173,7 +173,7 @@ isCellularDataEnabled(callback: AsyncCallback\): void **示例:** -``` +```js data.isCellularDataEnabled((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -197,7 +197,7 @@ isCellularDataEnabled(): Promise\ **示例:** -``` +```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\) **示例:** -``` +```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\ **示例:** -``` +```js let promise = data.isCellularDataRoamingEnabled(0); promise.then((data) => { console.log(`test success, promise: data->${JSON.stringify(data)}`); diff --git a/zh-cn/application-dev/reference/apis/js-apis-webSocket.md b/zh-cn/application-dev/reference/apis/js-apis-webSocket.md index 26a1f83162..9d1d0455e7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webSocket.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webSocket.md @@ -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\): 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 **示例:** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" let promise = ws.connect(url); @@ -215,7 +215,7 @@ send\(data: string | ArrayBuffer, callback: AsyncCallback\): void **示例:** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" ws.connect(url, (err, value) => { @@ -254,7 +254,7 @@ send\(data: string | ArrayBuffer\): Promise **示例:** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" ws.connect(url, (err, value) => { @@ -286,7 +286,7 @@ close\(callback: AsyncCallback\): void **示例:** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" ws.close((err, value) => { @@ -318,7 +318,7 @@ close\(options: WebSocketCloseOptions, callback: AsyncCallback\): void **示例:** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" ws.close({ @@ -358,7 +358,7 @@ close\(options?: WebSocketCloseOptions\): Promise **示例:** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" let promise = ws.close({ @@ -391,7 +391,7 @@ on\(type: 'open', callback: AsyncCallback\): 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\): 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\): 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\): 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'); ``` -- GitLab