按官网教程,自定义Controller基类
module.exports = app => {
class CustomController extends app.Controller {
success(data) {
this.ctx.body = {
success: true,
data,
};
}
}
app.Controller = CustomController;
}
在Controller中调用不到
module.exports = app => {
return class PostController extends app.Controller {
* list() {
this.success({id: 1});
},
};
};
你的第一段代码在哪里写的?
@dead-horse 在app.js中
egg-core 里面设置成不允许修改了,我修复一下,顺便写一个 example
定义成 getter 了,直接在 constructor 里面设置好了
删掉依赖重新安装下就可以了
同样的问题,已解决,谢谢大家~
Most helpful comment
删掉依赖重新安装下就可以了