0
我創建了一個叫做baseModel.js驗證和傳承
import { Validation } from 'aurelia-validation';
let id;
let version;
let validation;
@inject(Validation)
export class BaseModel {
constructor(validation) {
this.validation = validation;
}
}
我擴展它在supplierModel.js
import { BaseModel } from "./baseModel";
let apSupplierCode;
let discountRate;
export class Supplier extends BaseModel {
constructor() {
super();
super.validation = validation.on(this)
.ensure('apSupplierCode')
.isNotEmpty()
.hasLengthBetween(3, 6)
.ensure('discountRate')
.isNotEmpty()
.containsOnlyDigits()
.isBetween(10, 45.99);
}
}
我收到以下錯誤控制檯
以下基本類inner error: ReferenceError: validation is not defined
at new Supplier http://localhost:9000/dist/models/supplierModel.js:63:55)
我試着用get/set訪問器,super.validation和驗證,但它沒有區別。
爲什麼供應商無法在其父級(BaseModel)類中看到變量?