非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

console 只读特性在 WorkerGlobalScope interface returns a 控制台 object providing access to the browser console for the worker.

句法

var consoleObj = self.console;
					

A 控制台 对象。

范例

This property allows you to have access to a browser console for debugging purposes, inside a worker. So for example you could call

console.log('test');
					

inside a worker (which would basically be the equivalent of self.console.log('test'); , as these are being called on the worker scope, which can be referenced with WorkerGlobalScope.self ), to return a test message out to the browser console.

If you are calling console.log() DedicatedWorkerGlobalScope or other worker scope that acts on a single loaded window, that tab's web console will receive the logs. However, If you are calling console.log() SharedWorkerGlobalScope , the global browser console will receive the logs.

规范

Not yet part of any specification.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
console 弃用 非标 Chrome 4 Edge 12 Firefox 29
29
Before Firefox 30, the console would be of type WorkerConsole 而不是 控制台 .
IE Yes Opera Yes Safari Yes WebView Android 37 Chrome Android Yes Firefox Android 29
29
Before Firefox 30, the console would be of type WorkerConsole 而不是 控制台 .
Opera Android ? Safari iOS ? Samsung Internet Android Yes

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

另请参阅

元数据

  • 最后修改: