【发布时间】:2019-10-09 21:50:25
【问题描述】:
我尝试使用 vue-injector,但它可以使用我的 Vue (2.6.10) 和 Typescript (3.4.5) 版本进行编译。
我看到的其他选择很少。
在纯 typescript 方面,我看到 Inversify 和 TSyringe 之类的东西看起来不错,但不适用于开箱即用的 Vue。
这是反转:
Argument of type typeof App' is not assignable to parameter of type 'VueClass<Vue>'.
Type 'typeof App' is not assignable to type 'VueConstructor<Vue>'.
Types of parameters 'authService' and 'options' are incompatible.
Type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>>' is missing the following properties from type 'AuthService': app, scopes, login, logout, getAccount
export default class App extends Vue {
constructor(
@inject(AuthService) authService: AuthService
) {
super();
}
}
我假设我需要创建一个具有正确签名的类,但在我消失在那个兔子洞之前,是否有人对 Vue/Typescript/DI 有任何经验并且可以为我指出一个明智的解决方案的方向?
【问题讨论】:
标签: typescript vue.js dependency-injection vuejs2