[英]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.