此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

TextDecoder.fatal

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2020年1月⁩.

TextDecoder 接口的只读属性 fatal 是一个布尔值,表示错误模式是否是致命的。

如果这个值是 true,那么当解码器在解码时遇到格式错误的数据时,将抛出 TypeError 错误。如果值是 false,则解码器将使用替换字符 U+FFFD(�)替换无效的数据。属性值在 TextDecoder() 构造函数中设置。

一个布尔值,如果错误模式设置为 fatal,它将返回 true。否则返回 false,表示错误模式是“replacement”。

规范

Specification
Encoding
# ref-for-dom-textdecoder-fatal①

浏览器兼容性