为什么小程序多线程按照官方文档操作总是报错,怎么试也没有用?
[代码]{[代码][代码] [代码][代码]"workers"[代码][代码]: [代码][代码]"workers"[代码][代码]}[代码] [代码] [代码] [代码]workers/request/index.js[代码][代码]workers/request/utils.js[代码][代码]workers/response/index.js[代码][图片] request/idnex.js [代码]var[代码] [代码]utils = require([代码][代码]'./utils'[代码][代码])[代码] [代码]// 在 Worker 线程执行上下文会全局暴露一个 `worker` 对象,直接调用 worker.onMeesage/postMessage 即可[代码][代码]worker.onMessage([代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res)[代码][代码]})[代码] [图片] app.js [代码]var[代码] [代码]worker = wx.createWorker([代码][代码]'workers/request/index.js'[代码][代码]) [代码][代码]// 文件名指定 worker 的入口文件路径,绝对路径[代码][代码]//主线程向 Worker 发送消息[代码][代码]worker.postMessage({[代码][代码] [代码][代码]msg: [代码][代码]'hello worker'[代码][代码]})[代码][图片]