muerwre.github.io/content/Frontend/Vue/Adding global properties to component.md
2022-11-04 18:29:11 +06:00

539 B

The topic's fully covered in the official documentation and in Add global variable to window.

For example, you want to add global $http and $translate services to all of project's components:

// ~/index.d.ts or ~/custom.d.ts

import axios from 'axios'

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