我无法让 Google 网络字体在 express 3.0 中工作。
以标准方式加载字体似乎不起作用:
link(href='http://fonts.googleapis.com/css?family=Crete+Round')
但是以这些方式之一加载字体工作正常:
script(type="text/javascript")
WebFontConfig = {google: { families: [ 'Crete+Round::latin' ] }};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
或
style
@import url(http://fonts.googleapis.com/css?family=Crete+Round);
最佳答案
我在不包括 CSS 的 Express 3.0.0rc2 上遇到过类似的问题。我不确定这是 Jade 还是 Express 的问题,但是当我添加一个有效的 style.css
时,它工作得很好,就像这样:
link(rel='stylesheet', href='/stylesheets/style.css')
但是,如果我删除该行并插入,比如说 Twitter Bootstrap css 文件,我会得到奇怪的 HTML 输出。
link(rel='stylesheet', href='/bootstrap/css/bootstrap.min.css')
它只有在我有这样的东西时才有效:
link(rel='stylesheet', href='/bootstrap/css/bootstrap.min.css')
link(rel='stylesheet', href='/bootstrap/css/bootstrap-responsive.min.css')
link(rel='stylesheet', href='/stylesheets/style.css')
为什么?我不知道。 :-) 我认为这与解析和 HTML 输出有关。
关于node.js - Google 网络字体在 Express 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11962389/