我将 InversifyJS 与绑定和惰性注入装饰器一起使用,并且收到下一个错误:
找不到 serviceIdentifier: Symbol(ClassB) 的匹配绑定
这是代码:
inversify.config.ts
import { Container } from 'inversify';
import getDecorators from 'inversify-inject-decorators';
import { buildProviderModule, provide } from 'inversify-binding-decorators';
import Types from './types';
const container = new Container();
container.bind<MyType>(Types.MyType)
.to(MyType);
const { lazyInject } = getDecorators(container, false);
container.load(buildProviderModule());
export { container, lazyInject, provide };
Run Code Online (Sandbox Code Playgroud)
MyType.ts
import { inject, injectable } from 'inversify';
@injectable()
export class MyType{
constructor(
@inject(Q) private readonly Q: Q,
@inject(W) private readonly W: W,
@inject(E) private readonly E: E) { …Run Code Online (Sandbox Code Playgroud) typescript javascript-import inversifyjs javascript-decorators