我正在尝试在’css.scss’文件中添加背景图像.我一直收到这个错误: Invalid CSS after “…und-image: url(“: expected “)”, was “%= asset_path(…” (in /Users/caseyrees/Projects/citycreek/app/assets/styleshe
Invalid CSS after “…und-image: url(“: expected “)”, was “<%= asset_path(…”
(in /Users/caseyrees/Projects/citycreek/app/assets/stylesheets/custom.css.scss)
这就是我写它的方式:
background-image: url( <%= asset_path 'home/facebook.png' %>);
如果我将文件扩展名更改为“css.erb”,它似乎可以正常工作.我需要它来使用.scss文件扩展名.
你不想写assert_path,试试这个,(来自我工作的css.scss文件之一)background: url(image_path('footer_bg.jpg')) repeat-x center top;
我的footer_bg.jpg图片在app / asset / images中
HTH