提交 86a206a6 编写于 作者: W wangzhaoyong

Worker doc fix

issue: https://gitee.com/openharmony/docs/issues/I62RHZSigned-off-by: Nwangzhaoyong <wangzhaoyong@huawei.com>
Change-Id: I73ca361732a8a56cd2decba8acaeaba1c08e481f
上级 1b2e8e73
......@@ -422,7 +422,7 @@ dispatchEvent(event: Event): boolean
```js
const workerInstance = new worker.ThreadWorker("workers/worker.js");
workerInstance.dispatchEvent({type:"alert"});
workerInstance.dispatchEvent({type: "alert"});
```
......@@ -444,7 +444,7 @@ workerInstance.removeAllListener();
## ThreadWorkerGlobalScope<sup>9+</sup>
Worker线程用于与宿主线程通信的类,通过postMessage接口发送消息给宿主线程、close接口销毁Worker线程。DedicatedWorkerGlobalScope类继承[GlobalScope<sup>9+</sup>](#globalscope9)
Worker线程用于与宿主线程通信的类,通过postMessage接口发送消息给宿主线程、close接口销毁Worker线程。ThreadWorkerGlobalScope类继承[GlobalScope<sup>9+</sup>](#globalscope9)
### postMessage<sup>9+</sup>
......@@ -609,7 +609,7 @@ workerInstance.addEventListener("alert", (e)=>{
## GlobalScope<sup>9+</sup>
Worker线程自身的运行环境,WorkerGlobalScope类继承[WorkerEventTarget](#workereventtarget9)
Worker线程自身的运行环境,GlobalScope类继承[WorkerEventTarget](#workereventtarget9)
### 属性
......@@ -1401,7 +1401,7 @@ parentPort.onerror = function(e){
```js
// main.js
import worker from '@ohos.worker';
const workerInstance = new worker.Thread("workers/worker.js");
const workerInstance = new worker.ThreadWorker("workers/worker.js");
workerInstance.postMessage("message from main to worker");
workerInstance.onmessage = function(d) {
// 当worker线程传递obj2时,data即为obj2。data没有Init、SetName的方法
......@@ -1413,12 +1413,9 @@ workerInstance.onmessage = function(d) {
import worker from '@ohos.worker';
const parentPort = worker.workerPort;
class MyModel {
name:"undefined"
Init() {
this.name = "wzy"
this.age = 18
}
SetName() {
this.name = "WZY"
this.name = "MyModel"
}
}
parentPort.onmessage = function(d) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册