当前位置:网站首页>egg.js中Class constructor BaseContextClass cannot be invoked without ‘new‘解决方法
egg.js中Class constructor BaseContextClass cannot be invoked without ‘new‘解决方法
2022-08-10 00:26:00 【抗争的小青年】
错误翻译过来就是:没有’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
边栏推荐
- 数据的存储——C语言
- Xi'an biotin-tetrapolyethylene glycol-amide-4phenol light yellow semi-solid
- 【Django】缓存
- pyhton之问~~~~~if __name__ == ‘__main__‘:是什么?
- Quick responsiveness intelligent/smart responsiveness of polyethylene glycol type nano/reduction response hydrogels research and preparation
- C language pointer practice questions
- 你有对象类,我有结构体,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang结构体(struct)的使用EP06
- How to activate the payment function on WeChat official account?
- 3.9 - 正规表达式和正规集 3.10 - 有限自动机
- c语言指针练习题
猜你喜欢
随机推荐
Docker interview question 2--get the number of database connections and docker-compose
Aptos 深度解读:机遇、挑战与风险
最高月薪15K,谁有历经千辛万苦的意志,谁就能收获属于自己的成功~
由生物素参与的D-Biotinol,CAS号:53906-36-8具体特性说明
即时通讯开发如何撸一个WebSocket服务器
宝塔实测-搭建LightPicture开源图床系统
03|Process Control
什么是一网统管?终于有人讲明白了
【毕业设计】基于ESP32的在线墨水屏桌面摆件 -物联网 单片机 嵌入式
初步认识对象
XSS详解及复现gallerycms字符长度限制短域名绕过
Pyscript,创建一个能执行crud操作的网页应用
服装店管理系统如何推送活动?
3.9 - 正规表达式和正规集 3.10 - 有限自动机
Prometeus 2.31.0 新特性
R语言使用cox函数构建生存分析回归模型、使用subgroupAnalysis进行亚组分析并可视化森林图
算法---整数替换(Kotlin)
游泳馆系统次卡的设置有哪些细节?
c语言指针练习题
Data storage - the C language








