Sanitizer:setComments() 方法
Sanitizer 介面的 setComments() 方法用於設定清理器是否允許或移除註釋。
此方法會設定此清理器配置中的 comments 屬性。
語法
js
setComments(allow);
引數
allow-
如果允許註釋,則為
true;如果移除註釋,則為false。
返回值
無 (undefined)。
示例
如何清理註釋
下面的程式碼展示了 setComments() 方法的基本用法。
js
// Create sanitizer (in this case the default)
const sanitizer = new Sanitizer();
// Allow comments
sanitizer.setComments(true);
// Remove comments
sanitizer.setComments(false);
規範
| 規範 |
|---|
| HTML Sanitizer API # dom-sanitizer-setcomments |
瀏覽器相容性
載入中…