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

!12047 Modify the example

Merge pull request !12047 from 小马奔腾/master
......@@ -46,13 +46,13 @@ let xml =
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
let conv = new convertxml.convertToJSObject();
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.convert(xml, options));
let result = JSON.stringify(conv.convertToJSObject(xml, options));
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"}]}]}]}
......
......@@ -165,7 +165,7 @@ forEach(callbackFn: (value: string, key: string, searchParams: this) => void, th
```js
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);
});
```
......
......@@ -668,8 +668,7 @@ parseRationalNumber(numerator: number,denominator: number): RationalNumber
**示例:**
```js
let rationalNumber = new util.RationalNumber();
rationalNumber.parseRationalNumber(1,2)
let rationalNumber = util.RationalNumber.parseRationalNumber(1,2)
```
### constructor<sup>(deprecated)</sup>
......@@ -1488,7 +1487,8 @@ contains(key: object): boolean
```js
let pro = new util.LRUCache();
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
```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) {
import worker from '@ohos.worker';
const parentPort = worker.workerPort;
class MyModel {
name:"undefined"
name = "undefined"
Init() {
this.name = "MyModel"
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册