流星 + 引导 3 字形不起作用
Meteor + Bootstrap 3 Glyphicons not working
我一直在尝试将引导程序 3 与 Meteor 一起使用,但是引导程序有效,但 Glyphicon 不起作用。导入带有图标的文件时,会显示以下错误:
Resource interpreted as Font but transferred with MIME type text/html:"http://localhost:3000/client/fonts/glyphicons-halflings-regular.woff".
你把这个文件放在了错误的位置。Meteor 应作为单独实体提供的所有文件都应放置在目录中/public
。
当 Meteor 服务器获取路径时,它首先检查 /public
中是否有匹配的文件。如果有,则提供。否则,Meteor 会将自身作为 HTML 文件加载到客户端,然后在所选的客户端路由器中处理路径。
在您的情况下,您尝试访问/client
目录中的文件,而不是/public
目录中的文件,因此会发生第二种情况。结果,浏览器会获得带有 Meteor 代码的 HTML 文件,它应该在其中接收字体。
为了解决这个问题,将字体移动到像/public/fonts/glyphicons-halflings-regular.woff
这样的地方,然后通过/fonts/glyphicons-halflings-regular.woff
访问在Bootstrap的CSS中使用的任何地方。
这是我自己的 bootstrap3 包结构,它为我按预期工作:
bootstrap3
|-> dist (bootstrap3 directory containint js/, css/ and fonts/)
|-> bootstrap_override.css (override fonts paths)
|-> package.js (package definition)
bootstrap_override.css
@font-face{
font-family:'Glyphicons Halflings';
src:url('/packages/bootstrap3/dist/fonts/glyphicons-halflings-regular.eot');
src:url('/packages/bootstrap3/dist/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
url('/packages/bootstrap3/dist/fonts/glyphicons-halflings-regular.woff') format('woff'),
url('/packages/bootstrap3/dist/fonts/glyphicons-halflings-regular.ttf') format('truetype'),
url('/packages/bootstrap3/dist/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
包.js
Package.describe({
summary:"bootstrap 3.0 packaged for Meteor."
});
Package.on_use(function(api){
api.use(["jquery"],"client");
//
api.add_files([
// bootstrap fonts
"dist/css/bootstrap.min.css",
"dist/css/bootstrap-theme.min.css", (optional bootstrap2 lookalike theme)
// bootstrap javascript
"dist/js/bootstrap.min.js"
],"client");
api.add_files([
"dist/fonts/glyphicons-halflings-regular.eot",
"dist/fonts/glyphicons-halflings-regular.ttf",
"dist/fonts/glyphicons-halflings-regular.svg",
"dist/fonts/glyphicons-halflings-regular.woff"
],"client",{
// undocumented hint : do not bundle those files along with with js/html resources
isAsset:true
});
api.add_files([
// overriding css
"bootstrap_override.css"
],"client");
});
这个包指定字体是特殊的资源,不应该与常规的js/html一起捆绑在客户端上,引用核心开发人员David Glasser的话"它需要未经处理和可单独获取"。(见 https://github.com/meteor/meteor/issues/1357)
bootstrap_override.css 文件是使用我们的包相关绝对路径覆盖 bootstrap 中定义的默认相对路径所必需的.css 个。
您也可以从大气中使用 bootstrap-3 软件包。(https://atmosphere.meteor.com/package/bootstrap-3)
meteor 文件夹,>构建>程序> web.browser>包> twbs_bootstrap> dist> 字体来查找字形库,我只是将它们复制到 ''public''fonts。
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 监视函数从服务返回不起作用,但作用域函数起作用
- 幻灯片滚动javascript不起作用
- 简单的javascript在Shopify中不起作用
- Recaptcha在IE7和IE8中不起作用
- Ember Data DS.Model's set函数不起作用
- JsFiddle上的鼠标事件不起作用
- 我的AngularJS表达式没有'不起作用
- 点击按钮输入不起作用
- 面向对象的Javascript代码在IE7中不起作用
- 分部隐藏在jquery中不起作用
- 在phonegap应用程序内部重定向不起作用
- Array.length似乎不起作用;console.log则显示其他情况
- $ionicplatform内的$scope不;不起作用
- 我的javascript for循环不起作用
- Meteor-添加用户自定义字段的方法不起作用
- 为什么 .focus() 不起作用,而 .css(“color”,“red”) 在同一个选择器上起作用
- 在每个细胞剂量上添加字形图标'不起作用
- 流星 + 引导 3 字形不起作用
- Highcharts - Series工具提示在绘制x轴上之字形的线条时不起作用