现在我实现了用于 API 连接的 RepositoryFactory 模式。
https://medium.com/canariasjs/vue-api-calls-in-a-smart-way-8d521812c322
在repository.ts中,我编写了$axios。
import testRepository from '~/api/testRepository'
export interface Repositories {
hoge: testRepository
}
export default function ({ $axios }, inject) { # <- error on $axios
const hoge = new testRepository ($axios)
const repositories: Repositories = {
hoge
}
inject('repositories', repositories)
}
但它显示错误消息 Binding 元素 '$axios' 隐式具有 'any' type.ts(7031)。
我想知道 $axios 的正确类型是什么
{ $axios } :any 可以解决它,但我想知道“$axios”的确切类型。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
您是否在 tsconfig.json 文件中添加了 @nuxt/types 和 @nuxtjs/axios ? 如果需要更多信息,可以查看:https://axios.nuxtjs.org/setup
{ "compilerOptions": { "types": [ "@nuxt/types", "@nuxtjs/axios" ] } }