我知道这个问题之前已经被问过了,但是我读的所有内容都没有帮助。
在执行ng build
之后,没有错误。
在执行'ng build --prod'之后。
ERROR in src/app/catalog/product/product.component.html(19,43): : Property 'length' does not exist on type 'object'.
src/app/catalog/product/product.component.html(36,39): : Property 'specs' does not exist on type 'Object'.
src/app/catalog/product/product.component.html(58,8): : Property 'config' does not exist on type 'ProductComponent'. Did you mean 'Configs'?
src/app/catalog/product/product.component.html(59,14): : Property 'config' does not exist on type 'ProductComponent'. Did you mean 'Configs'?
src/app/catalog/product/add/add.component.html(14,8): : Property 'pre_configs' does not exist on type 'object'.
src/app/catalog/product/add/add.component.html(30,28): : Property 'sets' does not exist on type 'object'.
src/app/catalog/product/add/add.component.html(70,32): : Property 'price' does not exist on type 'object'.
src/app/catalog/product/add/add.component.html(70,32): : Property 'price' does not exist on type 'object'.
src/app/navigation/mini/mini-search/mini-search.component.html(9,5): : Property 'searchText' does not exist on type 'MiniSearchComponent'.
src/app/navigation/mini/mini-search/mini-search.component.html(13,5): : Property 'searchText' does not exist on type 'MiniSearchComponent'.
src/app/catalog/single/single.component.html(5,24): : Property 'id' does not exist on type 'any[]'.
src/app/catalog/single/single.component.html(74,25): : Property 'id' does not exist on type 'any[]'.
src/app/navigation/maga/maga.component.html(5,8): : Property 'name' does not exist on type 'any[]'.
这是一个非常烦人的问题。我开始逐个查看错误,并将继续这样做,但这些错误似乎没有意义,而且这种方法将花费我数小时的时间。有人能指导我从哪里开始或为什么在使用--prod
后会出现新错误吗?
更新:其中一个错误示例
在我的组件html中
<div *ngIf="sample?.specs">
<div class="spec-section" *ngFor="let section of sample.specs">
<h2>{{section.name}}</h2>
</div>
</div>
ng build --prod
后出现错误。
ERROR in ../product/product.component.html(37,12): : Property 'specs' does not exist on type 'Object'.
以下是获取
sample
组件的代码。constructor(public configsService: ConfigsService) {
this.sample = configsService.sample_data;
}
在执行
ng serve
或部署ng build
后,前端看起来/运行得很好。错误只在执行ng build --prod
期间出现。