当前位置:网站首页>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
边栏推荐
- Redis redisTemplate.execute 执行锁
- Summary of basic operations of c language files
- What should I do if there is no sound after reinstalling the system in win10?
- -骑士巡游-
- pyhton之问~~~~~if __name__ == ‘__main__‘:是什么?
- MySQL最大连接数限制如何修改
- Stanford CS143 速通PA1教程
- What do you know about FITC-labeled biotin (FITC-biotin|CAS: 134759-22-1)?
- [NCTF2019]True XML cookbook-1|XXE漏洞
- Solving for the number of mines
猜你喜欢
XSS高级 svg 复现一个循环问题以及两个循环问题
最高月薪15K,谁有历经千辛万苦的意志,谁就能收获属于自己的成功~
What do you know about FITC-labeled biotin (FITC-biotin|CAS: 134759-22-1)?
Mysql database ALTER basic operations
3.9 - 正规表达式和正规集 3.10 - 有限自动机
Xi'an biotin-tetrapolyethylene glycol-amide-4phenol light yellow semi-solid
CAS:183896-00-6 (Biotin-PEG3-C3-NH2) PEG衍生物
pytest:如何在测试中编写和报告断言
How to turn off system protection in Win11?How to turn off the system protection restore function?
365 days challenge LeetCode1000 questions - Day 052 Step by step summation to get the minimum value of positive numbers Greedy
随机推荐
el-input保留一位小数点
How to turn off system protection in Win11?How to turn off the system protection restore function?
Pagoda measurement - building LightPicture open source map bed system
嵌入式Qt-实现两个窗口的切换
由生物素参与的D-Biotinol,CAS号:53906-36-8具体特性说明
无js实现弹出层效果
阿里云混合云管理平台多Region架构
-Pickling peanuts-
CVPR22 Oral|通过多尺度token聚合分流自注意力,代码已开源
Kubernetes服务接入Istio
Biotin-Cy2 Conjugate, Biotin-Cy2 Conjugate_Cy2 Biotin Conjugate
Koa中间件next实现
手把手教你编写性能测试用例
-Knight Parade-
Win7怎么把控制面板添加到右键菜单
Leetcode81. 搜索旋转排序数组 II
Tensor flow 踩坑记
Solving for the number of mines
地雷数量求解
【毕业设计】基于ESP32的在线墨水屏桌面摆件 -物联网 单片机 嵌入式