[英]Rails Bootstrap glyphicons
So I have been having a lot of issues with getting bootstraps glyphicons
working.所以我在让bootstraps glyphicons
工作时遇到了很多问题。 I have finally been able to get them to show on site.我终于能够让他们在现场展示。 The only problem that I am now having, is I get the following errors in my DOM:我现在遇到的唯一问题是我的 DOM 中出现以下错误:
GET http://localhost:3000/fonts/glyphicons-halflings-regular.woff2 jquery.self-660adc5….js?body=1:3734
GET http://localhost:3000/fonts/glyphicons-halflings-regular.woff localhost/:1
GET http://localhost:3000/fonts/glyphicons-halflings-regular.ttf 404 (Not Found) localhost/:1
Just so everyone is aware, when I select jquery.self-660adc5...js?body=1:3734
I get taken to the following line of code: support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
只是让每个人都知道,当我选择jquery.self-660adc5...js?body=1:3734
我会看到以下代码行: support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
In my terminal I get the following:在我的终端中,我得到以下信息:
Started GET "/fonts/glyphicons-halflings-regular.woff2" for ::1 at 2016-04-18 21:57:17 -0600
ActionController::RoutingError (No route matches [GET] "/fonts/glyphicons-halflings-regular.woff2")
I currently have all bootstrap glyphicon files in vendor/assets/fonts/
我目前在vendor/assets/fonts/
拥有所有引导程序字形文件
glyphicons-halflings-regular.eot glyphicons-halflings-regular.woff
glyphicons-halflings-regular.svg glyphicons-halflings-regular.woff2
glyphicons-halflings-regular.ttf
In my application.css
folder I have:在我的application.css
文件夹中,我有:
@import "bootstrap-sprockets";
@import "bootstrap";
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../assets/glyphicons-halflings-regular.eot');
src: url('../assets/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../assets/glyphicons-halflings-regular.woff') format('woff'), url('../assets/glyphicons-halflings-regular.ttf') format('truetype'), url('../assets/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
In application.rb
在application.rb
config.assets.paths << "#{Rails}/vendor/assets/fonts"
config.assets.precompile += %w(.svg .eot .woff .ttf .woff2)
In mime_types.rb
在mime_types.rb
Rack::Mime::MIME_TYPES['.woff'] = 'application/x-font-woff'
I guess where I am confused is that the glyphicons
are showing up and working, however, I am still getting the error in the DOM as well as in my terminal that these files cannot be found.我想我感到困惑的地方是glyphicons
正在显示并正常工作,但是,我仍然在 DOM 以及我的终端中遇到错误,无法找到这些文件。 Any suggestions on how I can handle this?关于我如何处理这个的任何建议? I initially had the gem 'bootstrap-sass', '3.2.0.0'
installed but ultimately just dl'd the bootstrap package and added it to my project.我最初安装了gem 'bootstrap-sass', '3.2.0.0'
但最终只是将引导程序包放入我的项目中。
Unfortunately I have yet to resolve this issue.不幸的是,我还没有解决这个问题。 For now I have included the Bootstrap CDN keys:现在我已经包含了 Bootstrap CDN 密钥:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
This obviously removes the errors for now.这显然暂时消除了错误。 If anyone else has any solution or needs more information on how to solve this issue please do comment.如果其他人有任何解决方案或需要有关如何解决此问题的更多信息,请发表评论。 I will be most eager to hear your thoughts.我将非常渴望听到您的想法。
您仍然需要将woff2
文件添加到资产管道中:
config.assets.precompile += %w(.svg .eot .woff .woff2 .ttf)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.