【发布时间】:2021-02-20 15:28:29
【问题描述】:
我在使用 Cloudinary with Angular 时遇到问题。 如果我像这样添加一个简单的图像:
<cl-image class="img-fluid" [public-id]="brand.image.publicId" dpr="auto" crop="scale">
<cl-placeholder type="pixelate">
</cl-placeholder>
<cl-transformation quality="auto" fetch-format="auto" width="500">
</cl-transformation>
</cl-image>
这很好用。 如果我尝试添加宽度:
<cl-image class="img-fluid" [public-id]="brand.image.publicId" dpr="auto" crop="scale">
<cl-placeholder type="pixelate">
</cl-placeholder>
<cl-transformation width="150" crop="thumb">
</cl-transformation>
<cl-transformation quality="auto" fetch-format="auto" width="500">
</cl-transformation>
</cl-image>
这也有效。但我希望我的宽度是一个变量,而不是静态宽度。所以我将代码更新为:
<cl-image class="img-fluid" [public-id]="brand.image.publicId" dpr="auto" crop="scale" *ngIf="width">
<cl-placeholder type="pixelate">
</cl-placeholder>
<cl-transformation [width]="width" crop="thumb">
</cl-transformation>
<cl-transformation quality="auto" fetch-format="auto" width="500">
</cl-transformation>
</cl-image>
这行不通。它显示图像,但没有调整它的大小,这不好。 注意这一行:
<cl-transformation [width]="width" crop="thumb">
就像它被忽略了一样,我还确保在使用 *ngIf="width" 设置宽度之前不会创建组件。
有人知道为什么这不起作用吗?
【问题讨论】:
标签: angular cloudinary