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


Vue.js ComponentCustomProperties用法及代碼示例

用於擴充組件實例類型以支持自定義全局屬性。

示例

import axios from 'axios'

declare module 'vue' {
  interface ComponentCustomProperties {
    $http: typeof axios
    $translate: (key: string) => string
  }
}

TIP

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

相關用法


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