给定以下 JS,如何设置对象的message
属性PlateCheck
?
var plateCheck = {
plateNumber: '',
message: '',
alertClass: '',
checkPlate: function (plateNumber) {
PlateCheckService.checkPlate(plateNumber).then(function (response) {
var data = response.data;
if (data.VehicleAtl !== null) {
this.message = "Hot!";
this.alertClass = 'alert-danger';
} else {
this.message = "Plate #" + data.PlateNumber + " is clean.";
this.alertClass = 'alert-success';
}
});
}
};
编辑
PlateCheckService.checkPlate(plateNumber)
返回一个承诺...