Angular2/Typescript编译错误:属性';车身';不存在于类型';答复';
不知道该怎么处理 我尝试定义类型为的接口Angular2/Typescript编译错误:属性';车身';不存在于类型';答复';,typescript,Typescript,不知道该怎么处理 我尝试定义类型为的接口 Error TS2339: Property 'body' does not exist on type 'Response'. 接口结果数据{ 正文:字符串 } 然后将其用作: interface ResultData<T> { body: string } this.getVerificationCode('1111111'){ 让url=`${remote}/auth/phoneNumber/${phoneNumber}`;
Error TS2339: Property 'body' does not exist on type 'Response'.
接口结果数据{
正文:字符串
}
然后将其用作:
interface ResultData<T> {
body: string
}
this.getVerificationCode('1111111'){
让url=`${remote}/auth/phoneNumber/${phoneNumber}`;
返回此。\u http.get(url)
.toPromise()
。然后((结果:ResultData)=>{
console.log(result.body);试试看
getVerificationCode(电话号码){
让url=`${remote}/auth/phoneNumber/${phoneNumber}`;
返回此。\u http.get(url)
.toPromise()
.然后((结果:对象)=>{
console.log(result.body);试试看
getVerificationCode(电话号码){
让url=`${remote}/auth/phoneNumber/${phoneNumber}`;
返回此。\u http.get(url)
.toPromise()
.然后((结果:对象)=>{
console.log(result.body);
interface ResultData<T> {
body: string
}
this.getVerificationCode('1111111') {
let url = `${remote}/auth/phoneNumber/${phoneNumber}`;
return this._http.get(url)
.toPromise()
.then( (result: ResultData<any> )=> {
console.log(result.body); <--- ERROR
});
Error TS2345: Argument of type '(result: ResultData<any>) => void' is not assignable to parameter of type '(value: Response) => void | PromiseLike<void>'.
Types of parameters 'result' and 'value' are incompatible.
Type 'Response' is not assignable to type 'ResultData<any>'.
Property 'body' is missing in type 'Response'.
getVerificationCode(phoneNumber) {
let url = `${remote}/auth/phoneNumber/${phoneNumber}`;
return this._http.get(url)
.toPromise()
.then((result: Object) => {
console.log(result.body); <--- ERROR
});
}