bearcat 0.3.4 發佈 -- 優化依賴注入寫法

在 0.3.4 版本中,依賴注入的描述,能夠更加的隨意,再也不強制要求必須是 this.$xxId 的形式git

如下的寫法也支持github

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.orgthis

相關文章
相關標籤/搜索