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 be52a524fc6ff53b6354aa909307bdc149ffe219..3f4c3ecae415070bbb984f2874c7f707b62ff41b 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md
@@ -9,7 +9,7 @@
## 导入模块
-```js
+```ts
import convertxml from '@ohos.convertxml';
```
@@ -46,27 +46,27 @@ convertToJSObject(xml: string, options?: ConvertOptions) : Object
**示例:**
-```js
+```ts
try {
- let xml =
- '' +
- '' +
- ' Happy' +
- ' Work' +
- ' Play' +
- '';
- let conv = new convertxml.ConvertXML()
- let options = {
- trim: false, declarationKey: "_declaration",
- instructionKey: "_instruction", attributesKey: "_attributes",
- textKey: "_text", cdataKey: "_cdata", doctypeKey: "_doctype",
- commentKey: "_comment", parentKey: "_parent", typeKey: "_type",
- nameKey: "_name", elementsKey: "_elements"
- }
- let result = JSON.stringify(conv.convertToJSObject(xml, options));
- console.log(result);
+ let xml =
+ '' +
+ '' +
+ ' Happy' +
+ ' Work' +
+ ' Play' +
+ '';
+ let conv = new convertxml.ConvertXML()
+ let options: convertxml.ConvertOptions = {
+ trim: false, declarationKey: "_declaration",
+ instructionKey: "_instruction", attributesKey: "_attributes",
+ textKey: "_text", cdataKey: "_cdata", doctypeKey: "_doctype",
+ commentKey: "_comment", parentKey: "_parent", typeKey: "_type",
+ nameKey: "_name", elementsKey: "_elements"
+ }
+ let result = JSON.stringify(conv.convertToJSObject(xml, options));
+ console.log(result);
} catch (e) {
- console.log(e.toString());
+ console.log(e.toString());
}
// 输出(宽泛型)
// {"_declaration":{"_attributes":{"version":"1.0","encoding":"utf-8"}},"_elements":[{"_type":"element","_name":"note","_attributes":{"importance":"high","logged":"true"},"_elements":[{"_type":"element","_name":"title","_elements":[{"_type":"text","_text":"Happy"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Work"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Play"}]}]}]}
@@ -99,20 +99,20 @@ convert(xml: string, options?: ConvertOptions) : Object
**示例:**
-```js
+```ts
let xml =
- '' +
+ '' +
'' +
' Happy' +
' Work' +
' Play' +
'';
let conv = new convertxml.ConvertXML();
-let options = {trim : false, declarationKey:"_declaration",
- instructionKey : "_instruction", attributesKey : "_attributes",
- textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
- commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
- nameKey : "_name", elementsKey : "_elements"}
+let options: convertxml.ConvertOptions = {trim : false, declarationKey:"_declaration",
+ instructionKey : "_instruction", attributesKey : "_attributes",
+ textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
+ commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
+ nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options));
console.log(result);
// 输出(宽泛型)
diff --git a/zh-cn/application-dev/reference/apis/js-apis-uri.md b/zh-cn/application-dev/reference/apis/js-apis-uri.md
index c3f14431c3c490f82d03c2f9b87b555567826d65..c034d4ea47a7af80215adc474759210b7e878f09 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-uri.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-uri.md
@@ -7,7 +7,7 @@
## 导入模块
-```js
+```ts
import uri from '@ohos.uri'
```
@@ -47,7 +47,7 @@ import uri from '@ohos.uri'
**URI示例:**
-```js
+```ts
const result1 = new uri.URI("ftp://ftp.aaa.bbb.ccc/dddd/eee.txt");
console.log(result1.host) // ftp.aaa.bbb.ccc
console.log(result1.fragment) // null
@@ -118,12 +118,12 @@ constructor是URI的构造函数。
**示例:**
-```js
+```ts
let mm = 'https://username:password@host:8080/directory/file?foo=1&bar=2#fragment';
-new uri.URI(mm); // Output 'https://username:password@host:8080/directory/file?foo=1&bar=2#fragment';
+new uri.URI(mm);
```
-```js
-new uri.URI('https://username:password@host:8080'); // Output 'https://username:password@host:8080';
+```ts
+new uri.URI('https://username:password@host:8080');
```
@@ -143,7 +143,7 @@ toString(): string
**示例:**
-```js
+```ts
const result = new uri.URI('https://username:password@host:8080/directory/file?query=pppppp#qwer=da');
let result1 = result.toString();
```
@@ -175,7 +175,7 @@ equals(other: URI): boolean
**示例:**
-```js
+```ts
const uriInstance = new uri.URI('https://username:password@host:8080/directory/file?query=pppppp#qwer=da');
const uriInstance1 = new uri.URI('https://username:password@host:8080/directory/file?query=pppppp#qwer=da');
uriInstance.equals(uriInstance1);
@@ -202,7 +202,7 @@ equalsTo(other: URI): boolean
**示例:**
-```js
+```ts
const uriInstance = new uri.URI('https://username:password@host:8080/directory/file?query=pppppp#qwer=da');
const uriInstance1 = new uri.URI('https://username:password@host:8080/directory/file?query=pppppp#qwer=da');
let result = uriInstance.equalsTo(uriInstance1);
@@ -224,7 +224,7 @@ checkIsAbsolute(): boolean
**示例:**
-```js
+```ts
const uriInstance = new uri.URI('https://username:password@www.qwer.com:8080?query=pppppp');
console.log(`${uriInstance.checkIsAbsolute()}`); // true
const uriInstance1 = new uri.URI('xxx.com/suppliers.htm');
@@ -248,7 +248,7 @@ normalize(): URI
**示例:**
-```js
+```ts
const uriInstance = new uri.URI('https://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp');
console.log(uriInstance.path); // /path/path1/../path2/./path3
let uriInstance1 = uriInstance.normalize();
diff --git a/zh-cn/application-dev/reference/apis/js-apis-url.md b/zh-cn/application-dev/reference/apis/js-apis-url.md
index 6765de6b25e7ab6b8c8d219642ecf078445b888d..1284c3a056e655522723f4a9c575fe9431ece566 100755
--- a/zh-cn/application-dev/reference/apis/js-apis-url.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-url.md
@@ -27,7 +27,7 @@ URLParams的构造函数。
**示例:**
-```js
+```ts
let objectParams = new Url.URLParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]);
let objectParams1 = new Url.URLParams({"fod" : '1' , "bard" : '2'});
let objectParams2 = new Url.URLParams('?fod=1&bard=2');
@@ -53,7 +53,7 @@ append(name: string, value: string): void
**示例:**
-```js
+```ts
let urlObject = Url.URL.parseURL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new Url.URLParams(urlObject.search.slice(1));
paramsObject.append('fod', '3');
@@ -76,7 +76,7 @@ delete(name: string): void
**示例:**
-```js
+```ts
let urlObject = Url.URL.parseURL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new Url.URLParams(urlObject.search.slice(1));
paramsObject.delete('fod');
@@ -105,7 +105,7 @@ getAll(name: string): string[]
**示例:**
-```js
+```ts
let urlObject = Url.URL.parseURL('https://developer.exampleUrl/?fod=1&bard=2');
let params = new Url.URLParams(urlObject.search.slice(1));
params.append('fod', '3'); // Add a second value for the fod parameter.
@@ -129,10 +129,12 @@ entries(): IterableIterator<[string, string]>
**示例:**
-```js
-let searchParamsObject = new Url.URLParams("keyName1=valueName1&keyName2=valueName2");
-for (var pair of searchParamsObject.entries()) { // Show keyName/valueName pairs
- console.log(pair[0]+ ', '+ pair[1]);
+```ts
+let searchParamsObject = new Url.URLParams("keyName1=valueName1&keyName2=valueName2");
+let pair:Iterable