johnsoncodehk / vue-tsc

vue-tsc --noEmit && vite build
https://www.npmjs.com/package/vue-tsc
MIT License
241 stars 6 forks source link

How to define the objects mounted by app.config.globalProperties #26

Closed cool-delete closed 3 years ago

cool-delete commented 3 years ago

image

export const http = axios.create({ baseURL: 'http://localhost:4000', timeout: 10000, // headers:{"X-Requested-With":"XMLHttpRequest"}, withCredentials: false

}) export default { http, install(app: App) { app.config.globalProperties.$http = http } }

johnsoncodehk commented 3 years ago

Use provide / inject, see: https://v3.vuejs.org/guide/composition-api-provide-inject.html

Please ask TS question to Vue Discord.