angular - 绑定表达式不能在表达式 ANGULAR 7 的末尾包含链式表达式
问题描述
npm run build 时显示的错误
Parser Error: Binding expression cannot contain chained expression at the end of the expression [getImageUrl(image, true);] in E:/Work/JamesJ/Pixie/pixie-image-editor/source/src/app/image-editor-ui/panels/open-sample-image-panel/open-sample-image-panel.component.html@34:9 ("
<div class="samples" *ngIf="sampleImages" >
<img [ERROR ->][src]="getImageUrl(image, true);" *ngFor="let image of sampleImages" (click)="openSampleImage(image)"")
: Parser Error: Binding expression cannot contain chained expression at the end of the expression [getImageUrl(image, true);] in E:/Work/JamesJ/Pixie/pixie-image-editor/source/src/app/image-editor-ui/panels/open-sample-image-panel/open-sample-image-panel.component.html@34:9 ("
<div class="samples" *ngIf="sampleImages" >
<img [src]="getImageUrl(image, true);" [ERROR ->]*ngFor="let image of sampleImages" (click)="openSampleImage(image)">
</div>")
: Parser Error: Binding expression cannot contain chained expression at the end of the expression [getImageUrl(image, true);] in E:/Work/JamesJ/Pixie/pixie-image-editor/source/src/app/image-editor-ui/panels/open-sample-image-panel/open-sample-image-panel.component.html@34:9 ("ngIf="sampleImages" >
<img [src]="getImageUrl(image, true);" *ngFor="let image of sampleImages" [ERROR ->](click)="openSampleImage(image)">
</div>")
html代码是
<div class="samples" *ngIf="sampleImages" >
<img [src]="getImageUrl(image, true);" *ngFor="let image of sampleImages" (click)="openSampleImage(image)">
</div>
组件代码是:
public getImageUrl(image: SampleImage, useThumbnail = false) : string {
const url = (image.thumbnail && useThumbnail) ? image.thumbnail : image.url;
// prefix relative link with base url, if needed
if (url.indexOf('//') === -1) {
return this.config.getAssetUrl(url);
} else {
return url;
}
}
解决方案
删除分号:
<img [src]="getImageUrl(image, true)" ...>
推荐阅读
- php - 如何过滤使用 foreach 循环生成的数组的输出
- vuejs2 - I have error importing lodash in vue file
- python - 如何从查询中捕获值并将其用作另一个查询中的值
- postgresql - Why creation date for PostgreSQL tables is null?
- javascript - 如何在jquery中更改悬停事件
- python - 熊猫掩码返回错误值
- c - 线程退出后是否可以释放 C __thread 线程本地内存?
- python - 如何知道我的 python 程序的解释时间?
- r - 从表中提取有用信息以预测真实场景
- javascript - HTML,JS:根据选择隐藏和显示输入字段