当前位置:网站首页>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
边栏推荐
- Stanford CS143 速通PA1教程
- Quick responsiveness intelligent/smart responsiveness of polyethylene glycol type nano/reduction response hydrogels research and preparation
- 【软考软件评测师】软件测试基础知识
- Are the numbers entered symmetrical?
- 五种定位——粘性定位
- Docker interview question 2--get the number of database connections and docker-compose
- 宝塔实测-搭建LightPicture开源图床系统
- 开发IM即时通讯容易吗?需要什么技术
- Biotin-Cy2 Conjugate, Biotin-Cy2 Conjugate_Cy2 Biotin Conjugate
- win10重装系统后没声音怎么办?
猜你喜欢
3.11-程序基本的控制语句 3.12-表达式 3.13-数据类型 3.14-常量/变量 3.15-标识符
Leetcode82. 删除排序链表中的重复元素 II
最高月薪15K,谁有历经千辛万苦的意志,谁就能收获属于自己的成功~
Leetcode83. 删除排序链表中的重复元素
嵌入式Qt-实现两个窗口的切换
Redis 非关系型数据库学习(一) ---- Redis 的安装
渗透测试与攻防对抗——漏洞扫描&逻辑漏洞(Part1)
c语言指针练习题
Pagoda measurement - building LightPicture open source map bed system
3.4 - 编译与解释 3.5 - 编译过程 3.8 - 文法
随机推荐
el-input保留一位小数点
Interlay集成至Moonbeam,为网络带来interBTC和INTR
Xi'an biotin-tetrapolyethylene glycol-amide-4phenol light yellow semi-solid
-Pickling peanuts-
XSS详解及复现gallerycms字符长度限制短域名绕过
【CAS:41994-02-9 |Biotinyl tyramide】Biotinyl tyramide price
Aptos 深度解读:机遇、挑战与风险
商业模式及其 SubDAO 深入研究
Biotin-Cy2 Conjugate, Biotin-Cy2 Conjugate_Cy2 Biotin Conjugate
嵌入式Qt-实现两个窗口的切换
oracle的数据导入导出
渗透测试与攻防对抗——漏洞扫描&逻辑漏洞(Part1)
R语言使用glm函数构建logistic回归模型,使用forestmodel包的forest_model函数可视化逻辑回归模型对应的森林图
Redis redisTemplate.execute 执行锁
阿里云混合云管理平台多Region架构
C language pointer practice questions
Kubernetes YAML编写 讲解
最高月薪15K,谁有历经千辛万苦的意志,谁就能收获属于自己的成功~
开发IM即时通讯容易吗?需要什么技术
Leetcode80. 删除有序数组中的重复项 II