控制器调用父类abstract方法会直接返回输出
torns opened this issue · 2 comments
torns commented
/**
- 基础控制器
*/
import { Controller } from "egg";
export default abstract class BaseIndexController extends Controller {
public abstract getMyName():string;
}
/**
- 首页控制器
*/
import { Controller, Get } from 'egg-pig';
import BaseIndexController from './baseIndex';
@controller('/admin')
export default class IndexController extends BaseIndexController {
public getMyName(): string {
return 'China';
}
@get('/test')
public async test() {
let name = this.getMyName();
this.ctx.body={ name:name }
}
}
调用/admin/test本应该输出{ name:"China" },现在却直接输出China
yviscool commented
我看看,