当前位置:网站首页>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
边栏推荐
猜你喜欢

足不出户也能看星空

OSS-访问oss生成的url无法访问,直接下载问题

Penetration Testing and Offensive and Defense Confrontation - Vulnerability Scanning & Logic Vulnerability (Part1)

How to turn off system protection in Win11?How to turn off the system protection restore function?

改变社交与工作状态的即时通讯是什么呢?

ITK编译remote库

02| operator

Mysql数据库 ALTER 基本操作

XSS详解及复现gallerycms字符长度限制短域名绕过

惊掉你下巴,程序员编码竟然可以被 996 指数化
随机推荐
头脑风暴:单词拆分
生物素叠氮化物中的(CAS:1527486-16-3TAMRA-azide-PEG3-Biotin)反应的特点!
微服务【同步和异步通讯详解】第6章
Pyscript,创建一个能执行crud操作的网页应用
[obs] obsqsv11 hard coding and comparison with metartc codec
使用 GoogleTest 框架对 C 代码进行单元测试
XSS详解及复现gallerycms字符长度限制短域名绕过
7. type( )函数——查询数据类型
走出迷宫的最少步数2
-采花生-
Web性能测试模型小结
Stanford CS143 速通PA1教程
【CAS:41994-02-9 |Biotinyl tyramide】生物素基酪氨酰胺价格
C语言头文件组织与包含原则
【毕业设计】基于ESP32的在线墨水屏桌面摆件 -物联网 单片机 嵌入式
惊掉你下巴,程序员编码竟然可以被 996 指数化
ITK编译remote库
微信公众号如何开通支付功能?
02| operator
字符统计柱状图