错误翻译过来就是:没有’new’就无法调用类构造函数BaseContextClass
这个时候应该去看看函数是否写对,我的报错原因如下:
'use strict';
const Controller = require('egg').Controller;
+class mackController extends Controller() {
async index() {
const { ctx } = this;
ctx.body = '<h1>I am Mack</h1>'
}
}
module.exports = mackController
在继承Controller时,后面加了一个括号,把括号去掉便可正常运行。
'use strict';
const Controller = require('egg').Controller;
class mackController extends Controller {
async index() {
const { ctx } = this;
ctx.body = '<h1>I am Mack</h1>'
}
}
module.exports = mackController