Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何设置requirejs和Google Web字体?_Javascript_Requirejs_Google Font Api_Google Webfonts - Fatal编程技术网

Javascript 如何设置requirejs和Google Web字体?

Javascript 如何设置requirejs和Google Web字体?,javascript,requirejs,google-font-api,google-webfonts,Javascript,Requirejs,Google Font Api,Google Webfonts,我正在使用并试图将一些google web字体加载到我的脚本中使用。我发现了几个或多或少与github页面上的示例相似的示例 例如: 我还阅读了字体插件的源代码,并在我的示例中尝试了这一点,但仍然不起作用 Line 28: example: font!google,families:[Tangerine,Cantarell,Yanone Kaffeesatz:700] 这是到目前为止我的代码 requirejs.config({ font: '../bower_components/r

我正在使用并试图将一些google web字体加载到我的脚本中使用。我发现了几个或多或少与github页面上的示例相似的示例

例如:

我还阅读了字体插件的源代码,并在我的示例中尝试了这一点,但仍然不起作用

Line 28:
example: font!google,families:[Tangerine,Cantarell,Yanone Kaffeesatz:700]
这是到目前为止我的代码

requirejs.config({
    font: '../bower_components/requirejs-plugins/src/font',
    propertyParser: '../bower_components/requirejs-plugins/src/propertyParser'
});

define(['font!google,families:[Yanone Kaffeesatz:700]'], function(Font) {
    console.log(Font);
});
这是在控制台加载时触发的错误

Uncaught ReferenceError: WebFont is not defined
这发生在font.js的第38行


这里发生了什么?我觉得我缺少了某种配置或其他东西。如您所见,我使用的正是脚本所建议的导入示例。有没有实际使用过的示例?

经过一些调查,我发现,由于代码更改,实际上已经列出了一个bug。该漏洞是16天前列出的,目前仍处于打开状态,这对您没有帮助。同时,你应该能够对你的插件版本进行以下更改,这将把你绑在一起,直到修复被推到官方的bower存储库

在第37行的bower_components/requirejs plugins/src/font.js中,将其更改为:

req([(document.location.protocol === 'https:'? 'https' : 'http') +'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'], function(){
致:


“WebFont”正是被投诉的原因。

经过一些调查,我发现由于代码更改,实际上已经在列出了一个bug。该漏洞是16天前列出的,目前仍处于打开状态,这对您没有帮助。同时,你应该能够对你的插件版本进行以下更改,这将把你绑在一起,直到修复被推到官方的bower存储库

在第37行的bower_components/requirejs plugins/src/font.js中,将其更改为:

req([(document.location.protocol === 'https:'? 'https' : 'http') +'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'], function(){
致:

“网络字体”正是人们抱怨的对象