Webstorm 报告运行代码错误
Webstorm reports error with code that runs
我正在做一个关于 Angular 的教程,下面一行出现了 "Expecting newline or semicolon" 错误:
<tr *ngFor='#product of products'>
代码运行正常,如何让Webstorm忽略错误?
这是有错误的模板的全文:
<div class="panel panel-primary">
<div class="page-header">{{pageTitle}}</div>
<div class="panel-body">
<div class="row">
<div class="col-md-2">Filter By:</div>
<div class="col-md-4"><input type="text"/> </div>
</div>
<div class="row">
<div class="col-md-6"><h3>Filtered by:</h3></div>
</div>
</div>
<div class="table-responsive">
<table class="table" *ngIf="products && products.length">
<thead>
<tr>
<th><button class="btn btn-primary">Show Image</button> </th>
<th>Product</th>
<th>Code</th>
<th>Available</th>
<th>Price</th>
<th>Rating</th>
</tr>
</thead>
<tbody>
<tr *ngFor='#product of products'>
<td></td>
<td>{{product.productName}}</td>
<td>{{product.productCode}}</td>
<td>{{product.releaseDate}}</td>
<td>{{product.price}}</td>
<td>{{product.starRating}}</td>
</tr>
</tbody>
</table>
</div>
</div>
只需重新启动 webstorm,错误就消失了。我已经 运行 遇到了其他一些类似的错误,其中相同的解决方案已修复。花 50 美元并暂时使用 sublime 会很难过。
我有同样的错误,重新启动没有帮助。原来这是一个旧语法。从 Angular 2 beta.17 开始,语法从
<tr *ngFor='#product of products'>
至
<tr *ngFor='let product of products'>
在我的例子中,PHPStorm 2016.3.2 识别了这个新语法,但我使用旧语法的代码正在编译,因为它被设置为使用 Angular 2 beta.13。
为了在我的项目中修复它,我更改了上面的语法,然后在 package.json 中我更改了
"dependencies": {
"angular2": "2.0.0-beta.13",
"rxjs": "5.0.0-beta.2",
"zone.js": "0.6.6"
},
至
"dependencies": {
"angular2": "2.0.0-beta.17",
"rxjs": "5.0.0-beta.6",
"zone.js": "0.6.12"
},
和运行npm update
。对我来说,这一切都很好。
有关详细信息,请参阅 https://johnpapa.net/angular-2-ngfor/。
我正在做一个关于 Angular 的教程,下面一行出现了 "Expecting newline or semicolon" 错误:
<tr *ngFor='#product of products'>
代码运行正常,如何让Webstorm忽略错误? 这是有错误的模板的全文:
<div class="panel panel-primary">
<div class="page-header">{{pageTitle}}</div>
<div class="panel-body">
<div class="row">
<div class="col-md-2">Filter By:</div>
<div class="col-md-4"><input type="text"/> </div>
</div>
<div class="row">
<div class="col-md-6"><h3>Filtered by:</h3></div>
</div>
</div>
<div class="table-responsive">
<table class="table" *ngIf="products && products.length">
<thead>
<tr>
<th><button class="btn btn-primary">Show Image</button> </th>
<th>Product</th>
<th>Code</th>
<th>Available</th>
<th>Price</th>
<th>Rating</th>
</tr>
</thead>
<tbody>
<tr *ngFor='#product of products'>
<td></td>
<td>{{product.productName}}</td>
<td>{{product.productCode}}</td>
<td>{{product.releaseDate}}</td>
<td>{{product.price}}</td>
<td>{{product.starRating}}</td>
</tr>
</tbody>
</table>
</div>
</div>
只需重新启动 webstorm,错误就消失了。我已经 运行 遇到了其他一些类似的错误,其中相同的解决方案已修复。花 50 美元并暂时使用 sublime 会很难过。
我有同样的错误,重新启动没有帮助。原来这是一个旧语法。从 Angular 2 beta.17 开始,语法从
<tr *ngFor='#product of products'>
至
<tr *ngFor='let product of products'>
在我的例子中,PHPStorm 2016.3.2 识别了这个新语法,但我使用旧语法的代码正在编译,因为它被设置为使用 Angular 2 beta.13。
为了在我的项目中修复它,我更改了上面的语法,然后在 package.json 中我更改了
"dependencies": {
"angular2": "2.0.0-beta.13",
"rxjs": "5.0.0-beta.2",
"zone.js": "0.6.6"
},
至
"dependencies": {
"angular2": "2.0.0-beta.17",
"rxjs": "5.0.0-beta.6",
"zone.js": "0.6.12"
},
和运行npm update
。对我来说,这一切都很好。
有关详细信息,请参阅 https://johnpapa.net/angular-2-ngfor/。