簡體   English   中英

如何使用存儲在子表中的路徑顯示圖像 - Angular 和 Spring boot

[英]how can I display images using a path stored in a child table- Angular and Spring boot

我正在處理一個項目,其中圖像 url 存儲在子表(圖像)中並且圖像位於文件夾中。 我可以顯示圖像表中的所有圖像。

<ng-container matColumnDef="location">
      <th mat-header-cell *matHeaderCellDef>IMAGE</th>
      <td mat-cell *matCellDef="let productImage">
        <img
          height="100"
          width="100"
          src="{{ productImage?.location }}"
          class="rounded-circle img-fluid img-thumbnail"
          alt=""
        />
      </td>

但是當我嘗試以下操作時,圖像不會顯示,而其他數據可以通過父子關系訪問。 這個product.image.name工作正常。

<ng-container matColumnDef="location">
          <th mat-header-cell *matHeaderCellDef>Image</th>
          <td mat-cell *matCellDef="let product">
            <img
              height="100"
              width="100"
              src="{{ product.image.location }}"
              alt="{{ product.image.name }}"
              class="rounded-circle img-fluid img-thumbnail"
              alt=""
            />
          </td>
        </ng-container>

為了顯示圖像,我添加了image.setLocation(entity.getImage().getLocation()); 在我的產品 dto 轉換器中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM