close()
方法在
DedicatedWorkerGlobalScope
interface discards any tasks queued in the
DedicatedWorkerGlobalScope
's event loop, effectively closing this particular scope.
self.close();
If you want to close your worker instance from inside the worker itself, you can call the following:
close();
close()
and
self.close()
are effectively equivalent — both represent
close()
being called from inside the worker's inner scope.
注意
: There is also a way to stop the worker from the main thread: the
Worker.terminate
方法。
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'close()' in that specification. |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
close
|
Chrome Yes | Edge ≤79 | Firefox 54 | IE ? | Opera Yes | Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 54 | Opera Android Yes | Safari iOS ? | Samsung Internet Android Yes |
完整支持
兼容性未知
DedicatedWorkerGlobalScope
close()
postMessage()