未验证 提交 ef20945e 编写于 作者: O openharmony_ci 提交者: Gitee

!12047 Modify the example

Merge pull request !12047 from 小马奔腾/master
...@@ -46,13 +46,13 @@ let xml = ...@@ -46,13 +46,13 @@ let xml =
' <todo>Work</todo>' + ' <todo>Work</todo>' +
' <todo>Play</todo>' + ' <todo>Play</todo>' +
'</note>'; '</note>';
let conv = new convertxml.convertToJSObject(); let conv = new convertxml.ConvertXML()
let options = {trim : false, declarationKey:"_declaration", let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes", instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type", commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"} nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options)); let result = JSON.stringify(conv.convertToJSObject(xml, options));
console.log(result); console.log(result);
// 输出(宽泛型) // 输出(宽泛型)
// {"_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"}]}]}]} // {"_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"}]}]}]}
......
...@@ -165,7 +165,7 @@ forEach(callbackFn: (value: string, key: string, searchParams: this) => void, th ...@@ -165,7 +165,7 @@ forEach(callbackFn: (value: string, key: string, searchParams: this) => void, th
```js ```js
const myURLObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); const myURLObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
myURLObject.URLParams.forEach((value, name, searchParams) => { myURLObject.searchParams.forEach((value, name, searchParams) => {
console.log(name, value, myURLObject.searchParams === searchParams); console.log(name, value, myURLObject.searchParams === searchParams);
}); });
``` ```
......
...@@ -668,8 +668,7 @@ parseRationalNumber(numerator: number,denominator: number): RationalNumber ...@@ -668,8 +668,7 @@ parseRationalNumber(numerator: number,denominator: number): RationalNumber
**示例:** **示例:**
```js ```js
let rationalNumber = new util.RationalNumber(); let rationalNumber = util.RationalNumber.parseRationalNumber(1,2)
rationalNumber.parseRationalNumber(1,2)
``` ```
### constructor<sup>(deprecated)</sup> ### constructor<sup>(deprecated)</sup>
...@@ -1488,7 +1487,8 @@ contains(key: object): boolean ...@@ -1488,7 +1487,8 @@ contains(key: object): boolean
```js ```js
let pro = new util.LRUCache(); let pro = new util.LRUCache();
pro.put(2,10); pro.put(2,10);
let result = pro.contains(20); let obj = {1:"key"};
let result = pro.contains(obj);
``` ```
......
...@@ -423,7 +423,7 @@ dispatchEvent(event: Event): boolean ...@@ -423,7 +423,7 @@ dispatchEvent(event: Event): boolean
```js ```js
const workerInstance = new worker.ThreadWorker("workers/worker.js"); const workerInstance = new worker.ThreadWorker("workers/worker.js");
workerInstance.dispatchEvent({type: "alert"}); workerInstance.dispatchEvent({type: "alert", timeStamp:0});
``` ```
...@@ -1424,7 +1424,7 @@ workerInstance.onmessage = function(d) { ...@@ -1424,7 +1424,7 @@ workerInstance.onmessage = function(d) {
import worker from '@ohos.worker'; import worker from '@ohos.worker';
const parentPort = worker.workerPort; const parentPort = worker.workerPort;
class MyModel { class MyModel {
name:"undefined" name = "undefined"
Init() { Init() {
this.name = "MyModel" this.name = "MyModel"
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册