簡體   English   中英

沒有出現在heroku的背景圖像

[英]Background image not showing up in heroku

我在本地使用的heroku網站的背景圖片有問題

background-image: url('background_stripe.png');

有效但部署時文件已損壞

網站

我試過用了

background-image: image-url('background_stripe.png');
background-image: url(image-url('background_stripe.png'));
background-image: url(image_url('background_stripe.png'));

沒有一個在本地或在heroku上工作。

使用bash我發現heroku已將圖像文件命名為background_stripe.png,但它沒有哈希值,而且它的圖像已損壞

在您的production.rb中添加以下行

config.serve_static_assets = true
config.assets.compile = true

或者您可以嘗試使用本地預編譯資產

RAILS_ENV=production rake assets:precompile

當您的資產被編譯用於生產時,為了版本控制,它們會在其末尾添加“摘要”。 您應該使用asset_path('background_stripe.png')如果你在你的意見或定義的類image-url('background_stripe.png')如果你在你的SCSS文件,中引用定義它們的文檔

暫無
暫無

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

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