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

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

这个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 and a polyfill is available here