當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Vue.js app.compilerOptions.isCustomElement用法及代碼示例

指定一個檢查方法來識別本機自定義元素。

類型: (tag: string) => boolean

細節

如果標簽應被視為本機自定義元素,則應返回 true。對於匹配的標簽,Vue 會將其呈現為原生元素,而不是嘗試將其解析為 Vue 組件。

本機 HTML 和 SVG 標簽不需要在此函數中匹配 - Vue 的解析器會自動識別它們。

示例

// treat all tags starting with 'ion-' as custom elements
app.config.compilerOptions.isCustomElement = (tag) => {
  return tag.startsWith('ion-')
}

相關用法


注:本文由純淨天空篩選整理自vuejs.org大神的英文原創作品 app.compilerOptions.isCustomElement。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。