有几件事需要用这个来解决。首先,删除那个巨大的红色和蓝色斑点。其次,将“字体”目录移到资产目录中。然后,弹出你的 application.css 并确保它看起来像这样:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
@font-face {
font-family: 'FontAwesome';
src: url('fontawesome.eot');
src: url('fontawesome.eot?#iefix') format('embedded-opentype'), url('fontawesome.svg#fontawesome') format('svg'), url('fontawesome.woff') format('woff'), url('fontawesome.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
这将自动将“样式表”目录中的所有样式表加载到您的应用程序中,并注册您的字体以便 css 可以使用它。第三,弹出你的 application.js 文件并确保它看起来像这样:
/*
This is a manifest file that'll be compiled into application.js, which will include all the files
listed below.
Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
compiled file.
Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
about supported directives.
= require jquery
= require jquery_ujs
= require turbolinks
= require_tree .
*/
“require_tree”语句的作用与 application.css 中相同的语句完全相同;将所有内容加载到应用程序中。现在您可以在视图中调用 JavaScript!
希望这会有所帮助!