问题描述
我试图用Modernizr的(YepNope)加载动态生成的谷歌字体样式,但总是得到这个错误:
I'm trying to load a dynamically generated Google Font stylesheet using Modernizr (YepNope) but always get this error:
未捕获的SyntaxError:意外的令牌非法(CSS:1)
我的样式看起来是这样的:
My stylesheet looks like this:
http://fonts.googleapis.com/css?family=Holtwood+One+SC
和我通过
Modernizr.load({
load: ['css!http://fonts.googleapis.com/cssfamily=Holtwood+One+SC|Terminal+Dosis:700'],
callback:
function (url, result, key) {
console.log('loaded...!');
}
});
该网站说,这但由于某些原因,它只是将无法工作。我认为,资源被解析为一个脚本文件,这就是原因错误,但似乎无法使其工作=(
The website says this but for some reason it just won't work. I think the resource is parsed as a script file and that's what cause the error, but can't seem to make it work =(
用CSS!preFIX,你可以$ P $它PPEND任何文件名和yepnope
会像对待一个CSS文件。
任何人都有成功实现了类似的东西吗?
谢谢!
Anyone had success achieving something similar?Thanks!
推荐答案
请确保您添加的CSS preFIX文件到您yepnope副本。它像一个jQuery插件。
Make sure you are adding the css prefix file to your copy of yepnope. It works like a jQuery plugin.
您可以得到它:
<一个href=\"https://github.com/SlexAxton/yepnope.js/blob/master/$p$pfixes/yepnope.css-$p$pfix.js\">https://github.com/SlexAxton/yepnope.js/blob/master/$p$pfixes/yepnope.css-$p$pfix.js
这篇关于加载外部谷歌的字体样式与YepNope / Modernizr的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!