簡體   English   中英

Ember沒有在生產中加載一些圖像

[英]Ember isn't loading some images in production

我有一個Ember-cli 1.13應用程序,它有很多圖像存儲在公共目錄中。 現在,它將正確加載除特定組件中的圖像之外的所有圖像。

該組件的調用方式如下:

{{list-item url="list-url" name="List Name" price="240"}}

在內部,組件是這樣的:

<a href="http://example.com/{{url}}">
  <img src="/{{url}}.png" alt='Picture of the {{name}}' />
  <p class="item-name">{{name}}</p>
  ...
</a>

當我構建應用程序並啟動到heroku時,破碎的路徑就是

https://ridiculous-name-123123.herokuapp.com/list-item.png

哪個與localhost路徑相同,除非顯然有不同的域。

所有其他圖像在不與組件一起使用時起作用。

我哪里錯了?

當您使用生產環境構建時,您的資產會經歷一種稱為指紋識別的東西。

這里的問題似乎是你的“構建”url鏈接到非指紋文件,一個解決方案是將這些圖像移動到一個文件夾中,並將它們排除在ember-cli-build.js指紋ember-cli-build.js

var app = new EmberApp({
  fingerprint: {
    exclude: ['myComponentImages/']
  }
});

一個更好的解決方案是擁有完整的URL或傳遞一個更改顯示圖像的類,因為它們看起來像是靜態資產而不是用戶上傳的內容。

暫無
暫無

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

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