【发布时间】:2012-08-15 15:17:50
【问题描述】:
我无法让 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);
【问题讨论】:
-
奇怪...这可能是 express 3 的另一个新“功能”吗?我在 express 2 中做过几次没有问题。什么是 html 输出?你有什么奇怪的事情吗?
-
将
rel='stylesheet' type='text/css'属性添加到link标签是否有效?只要 Express 输出您期望的 HTML(检查源代码),就不是 Express/Jade 问题。 -
@3on 是的,我在 express 2 中没有任何问题
-
@BrandonTilley 我添加了 rel 和 type 并解决了问题。奇怪,我认为这些在 HTML5 中是不必要的。
标签: node.js express google-webfonts