我想在子类中定义一个静态属性,并在超类中访问它。那可能吗?
错误消息显示:model is not defined。
我只想让我的 FieldsetController 了解模型Fieldset:
import Model from './../../library/Model'
class Fieldset extends Model {
static name = 'fieldset'
static pluralName = 'fieldsets'
}
export default Fieldset
代码如下所示:
字段集/controller.js:
import Controller from './../../library/controller'
import Fieldset from './model'
class FieldsetController extends Controller {
static model = Fieldset
}
export default FieldsetController
库/controller.js:
class Controller {
static index(request, response) {
const data = model.getAll()
response.render(`admin/${model.pluralName}/index`)
}
static create(request, response) {}
static store(request, response) {}
...
}
export default Controller
慕村9548890
相关分类