编译我的应用程序时,我一直收到此错误。TS v2.0.3
app/components/profile.component.ts(13,12): error TS1005: '=' expected.
app/components/profile.component.ts(14,13): error TS1005: '=' expected.
app/components/profile.component.ts(16,10): error TS1005: '=' expected.
这是我的代码:
import { Component } from '@angular/core';
import { apiService } from '../services/api.service';
import 'rxjs/add/operator/map';
@Component({
moduleId: module.id,
selector: 'profile',
templateUrl: './profile.component.html'
})
export class ProfileComponent{
product[];
products[];
productTitle:string;
first[];
constructor(private _apiService:apiService){
this._apiService.getProduct().subscribe(product => {
//console.log(product.result.products);
this.product = product.result.products[0];
})
}
searchProd() {
this._apiService.updateTitle(this.productTitle);
this._apiService.getProduct().subscribe(productTitle => {
//console.log(productTitle.result.products);
this.first = productTitle.result.products[0];
this.products = productTitle.result.products;
})
}
}
我已经读过它,可能是因为TS中更新了语法,并且确实将其更新到了最新的2.1.0版本,但仍然出现了错误。
有人可以帮我吗?
看起来您需要这些行的类型说明符,例如:
product:any[];
products:any[];
first:any[];
如果您有更明确的类型可用,请改用那些类型。
编辑
正如对该问题的评论所指出的那样,使用any
可能有其自身的问题。在这种情况下,您将需要找到每个变量的正确类型并替换any
为该变量。一种可能性是,product
但如果看不到更多代码,就很难说出来。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句