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


Vue.js ComponentCustomProps用法及代碼示例

用於擴充允許的 TSX 道具,以便在 TSX 元素上使用未聲明的道具。

示例

declare module 'vue' {
  interface ComponentCustomProps {
    hello?: string
  }
}

export {}
// now works even if hello is not a declared prop
<MyComponent hello="world" />

TIP

增強必須放在模塊.ts.d.ts 文件中。有關詳細信息,請參閱Type Augmentation Placement

相關用法


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