免费视频公开课《下午茶时间 玩会儿数据注入 让DI带我装逼带我灰》(周一中午发布,现在还不能看,需要管家上班审核)视频地址 http://edu.csdn.net/course/detail/2927/85065
这个DI 库地址 https://github.com/liangzeng/method-cxt-di
const di = require("method-cxt-di");
class User {
constructor(name = "leo") {
this.name = name;
}
changename(name) {
this.name = name;
this.service.log();
}
}
let u = new User();
function dataProvider(method, cxt, args, methodname) {
return {
service: {
log() {
console.log("call method's name is " + methodname);
}
}
}
}
let u2 = di(u, dataProvider);
u2.changename("zeng");
// 输出 call method's name is changename