-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
我们知道,在Spring中组件是可以声明式注册和注入的
@Service
public class Knife implements Weapon {
// ...
}
public class Character {
@Autowired
public Knife setWeapon(Weapon weapon) {
// ...
}
}但是JavaScript在前端环境中,由于并没有类似ClassLoader的机制在运行前扫描所有的组件,所以纯粹前端环境是无法做自动注入的(根本不知道有哪些组件存在)
但是如果我们在构建过程或者后端有一定的工作可以扫描所有的文件,显然可以做到声明式的配置,因此后续可以考虑这样的工具,作用是扫描所有的.js文件查找所有注册的组件和注入关系
这个工具可以在构建过程中用以自动生成IoC的配置对象,也可以运行在后端动态输出ioc-config.js之类的文件(甚至内联在HTML中)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels