我是打字新手,所以请原谅我。我有一个程序,可以生成一个内置UI的网站。UI由一个文本框组成,该文本框接受vin号,存储它,然后传递给后端java程序执行一些后端处理。代码运行得很好。然而,该程序正在被重新利用,改为使用仲裁号码。所以我简单地替换了所有的"vin"";Arbitration"但是我得到了这个错误
srcappbuybackbuyback.component.html(6,32)::属性'Arbitration'不存在于类型'BuybackComponent'.">
这是它引用的代码
<td class="elt"><label class="title">Enter an Arbitration Number</label></td>
<td class="elt"><input (input)="Arbitration=$event.target.value" type="text" class="form-control"></td>
......
<td class="submit"><button type="button" class="btn btn-success" (click)="getBuyback()">Submit</button></td><td></td>
我不确定是否有另一个文件需要定义仲裁,然后才能在这里使用它,以便文本框接受输入的任何内容并将其传递给程序,但我可以使用一些帮助。
其他被vin修改并更改为仲裁的文件:
buyback.service.ts
.....
constructor(private http: HttpClient) { }
public getBuybackType() : Observable<BuybackType>{
return this.http.get<BuybackType>(this._bturl);
}
public getBuyback(Arbitration:String, buybackType: String ) : Observable<BuybackResponse>{ //modified
console.log("ENV URL: " + this._url);
console.log("Arbitration " + Arbitration); //modified
console.log("buybackType " + buybackType);
return this.http.post<BuybackResponse>(this._url, {
"Arbitration" : Arbitration, //modified
"buybackType": buybackType
});
}
}
buyback.component.ts
constructor(private _buybackService: BuybackService, private router: Router, private location: Location) { }
Arbitration:String; //modified
bType:String;
optionValue:String;
public sdata: BuybackResponse;
public bdata: BuybackType;
ngOnInit() {
if (sessionStorage.length == 0) {
this.location.replaceState('/');
this.router.navigate(['/']);
}
this._buybackService.getBuybackType().subscribe(data => this.bdata = data);
}
setType(e){
this.bType=e.target.value;
}
getBuyback() {
this._buybackService.getBuyback(this.Arbitration, this.bType).subscribe(data => this.sdata = data); //this arbitration modified
}
}
尝试将Arbitration:String;
更改为Arbitration:string;
。以下是对两者区别的一些解释:https://stackoverflow.com/a/14727461/9415247