在 0.3.4 版本中,依赖注入的描述,可以更加的随意,不再强制要求必须是 this.$xxId 的形式
以下的写法也支持
var Car = function() {
this.$id = "car";
this["$engine"] = null; // use []
var wheelName = "$wheel";
this[wheelName] = null; // use variable
};
Car.prototype["$light"] = null; // use variable in prototype
Car.prototype.run = function() {
this.$engine.run();
this.$light.shine();
this.$wheel.run();
console.log('car run...');
}
module.exports = Car;
example demo complex_function_annotataion
bearcat官网 bearcatjs.org
Bearcat 0.3.4版本中更新了依赖注入机制,允许开发者使用更灵活的方式进行依赖定义,例如使用变量或数组来指定依赖项。此更新简化了代码结构并提高了灵活性。
282

被折叠的 条评论
为什么被折叠?



