当前位置:网站首页>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
边栏推荐
- 开发IM即时通讯容易吗?需要什么技术
- JVM :运行时数据区-虚拟机栈
- 算法---整数替换(Kotlin)
- PEG derivative Biotin-PEG1-OH (cas: 95611-10-2, 2-biotinaminoethanol) advantage description
- Penetration Testing and Offensive and Defense Confrontation - Vulnerability Scanning & Logic Vulnerability (Part1)
- CMake 编译运行dpdk项目程序
- 最高月薪15K,谁有历经千辛万苦的意志,谁就能收获属于自己的成功~
- 初步认识对象
- 小程序中计算距离信息
- Characteristics of the (CAS:1527486-16-3TAMRA-azide-PEG3-Biotin) reaction in biotin azide!
猜你喜欢
3.1 - 程序设计语言 3.2 - 高级语言的特点及引用 3.3 - 静态/动态类型语言
Redis 非关系型数据库学习(一) ---- Redis 的安装
3.11-程序基本的控制语句 3.12-表达式 3.13-数据类型 3.14-常量/变量 3.15-标识符
365 days challenge LeetCode1000 questions - Day 052 Step by step summation to get the minimum value of positive numbers Greedy
渗透测试与攻防对抗——漏洞扫描&逻辑漏洞(Part1)
c语言结构体、函数以及指针练习(简单通讯录)
分析 20 个 veToken 生态系统协议 这种代币模型为何受欢迎?
《痞子衡嵌入式半月刊》 第 60 期
Aptos 深度解读:机遇、挑战与风险
DHCP——动态主机配置协议
随机推荐
深入理解Aarch64内存管理
Leetcode82. 删除排序链表中的重复元素 II
Aptos 深度解读:机遇、挑战与风险
R语言使用glm函数构建逻辑回归模型(logistic)、使用subgroupAnalysis函数进行亚组分析并可视化森林图
win10重装系统后没声音怎么办?
Win7怎么把控制面板添加到右键菜单
What do you know about FITC-labeled biotin (FITC-biotin|CAS: 134759-22-1)?
宽带由20M换为100M
[obs] obsqsv11 hard coding and comparison with metartc codec
C语言--数据的存储(上)
Mysql数据库 ALTER 基本操作
CVPR22 Oral|通过多尺度token聚合分流自注意力,代码已开源
DHCP——动态主机配置协议
基于Web的疫情隔离区订餐系统
Kubernetes服务接入Istio
五种定位——粘性定位
微信公众号如何开通支付功能?
阿里云混合云管理平台多Region架构
【Django】缓存
3.9 - 正规表达式和正规集 3.10 - 有限自动机