gpt4 book ai didi

javascript - Uncaught ReferenceError : Worker is not defined while trying to create a Worker within another Worker in Chrome

转载 作者:数据小太阳 更新时间:2023-10-29 04:13:30 27 4
gpt4 key购买 nike

link说:

Workers may spawn more workers if they wish. So-called sub-workers must be hosted within the same origin as the parent page. Also, the URIs for subworkers are resolved relative to the parent worker's location rather than that of the owning page. This makes it easier for workers to keep track of where their dependencies are.

但是当我尝试在另一个 Worker 中创建一个 Worker 时:

var worker = new Worker('foo.js');

我在 Chrome 中遇到异常。

Uncaught ReferenceError: Worker is not defined

IE 可以正常工作(令人惊讶)。这在某处记录了吗?是否有适当的跨浏览器方式从另一个 Worker 生成一个 Worker?在进行网络搜索时,我没有看到很多(或者更确切地说,没有)生成子进程的代码示例。

编辑:添加更多链接:
https://html.spec.whatwg.org/multipage/workers.html#delegation
https://whatwg.org/demos/workers/multicore/page.html (不适用于 Chrome)

最佳答案

你是对的。这是一个错误。您可以找到 reported bug here polyfill 是 available here .

关于javascript - Uncaught ReferenceError : Worker is not defined while trying to create a Worker within another Worker in Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33990712/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com