Property '$axios' does not exist on type 'ComponentPublicInstance<{}, {}, {}, {}, {}, Record<string, any>, Readonly<{}>, ComponentOptionsBase<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<...>, string>>'.Vetur(2339)
// 下面是在vue3.0定义源文件找到的一段说明注释
/**
* Custom properties added to component instances in any way and can be accessed through `this`
*
* @example
* Here is an example of adding a property `$router` to every component instance:
* ```ts
* import { createApp } from
* import { Router, createRouter } from
*
* declare module
* interface ComponentCustomProperties {
* $router: Router
* }
* }
*
* // effectively adding the router to every component instance
* const app = createApp({})
* const router = createRouter()
* app.config.globalProperties.$router = router
*
* const vm = app.mount(
* // we can access the router from the instance
* vm.$router.push(
* ```
*/
}
import '@vue/runtime-core'
import { AxiosInstance } from "axios";
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$axios: AxiosInstance;
}
}