Outputs an error message to the Web Console.

注意: 此特征可用于 Web 工作者 .

句法

console.error(obj1 [, obj2, ..., objN]);
console.error(msg [, subst1, ..., substN]);
console.exception(obj1 [, obj2, ..., objN]);
console.exception(msg [, subst1, ..., substN]);
					

注意: console.exception() 是别名化的 console.error() ; they are functionally identical.

参数

obj1 ... objN

A list of JavaScript objects to output. The string representations of each of these objects are appended together in the order listed and output.

msg

A JavaScript string containing zero or more substitution strings.

subst1 ... substN
JavaScript objects with which to replace substitution strings within msg . This gives you additional control over the format of the output.

把文本输出到控制台 在文档编制的 console 了解细节。

规范

规范 状态 注释
控制台 API
The definition of 'console.error()' in that 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
error Chrome 1 Edge 12 Firefox 4 IE 8 Opera 10.5 Safari 3 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 11 Safari iOS 1 Samsung Internet Android 1.0
Substitution strings Chrome Yes Edge 12 注意事项
12 注意事项
Before Edge 79, %c 不支持。
Before Edge 79, %d outputs a 0 if the specified value isn't a number.
Firefox 9 IE 10 注意事项
10 注意事项
%c 不支持。
%d outputs a 0 if the specified value isn't a number.
Opera ? Safari ? WebView Android Yes Chrome Android Yes Firefox Android 9 Opera Android ? Safari iOS ? Samsung Internet Android Yes

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

见实现注意事项。

另请参阅

元数据

  • 最后修改: