# Worker.postMessage(Object message)

Sends messages to the main thread/worker thread.

# Parameters

# Object message

The message to be sent, which must be a serializable object in the format of JavaScript key-value.

# Sample Code

In the worker thread

worker.postMessage({
  msg: 'hello from worker'
})

In the main thread

const worker = wx.createWorker('workers/request/index.js')

worker.postMessage({
  msg: 'hello from main'
})
点击咨询小助手