{ "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' }) |
这里官方效率贼低的
我也遇到这个问题了,坑啊。app.json的配置里面又没有阐述workers这一配置。
@小黄人酷递
@锐
@loading...
都散了吧,帖子这么久,官方也没回复,估计就这样了
相关的文档实在无力吐槽
同问,这个问题如何解决?
同样的问题
错误信息
Failed to load resource: the server responded
with
a status of 404 (Not Found)
VM6838:1 appServiceSDKScriptError
missing worker vendor code; at wx.createWorker
Error: missing worker vendor code
VM6838:1 thirdScriptError
Cannot read property
'postMessage'
of undefined;at App lifeCycleMethod onLaunch
function
TypeError: Cannot read property
'postMessage'
of undefined