要使用 WebFont 加载字体,我按照他们在此处的建议进行操作:https://developers.google.com/fonts/docs/webfont_loader
WebFontConfig = {
custom: { families: ['font1', 'font2', 'font3'],
urls: [ 'stylesheets/fonts.css' ] },
loading: function(){
console.log('loaded');
},
inactive: function(){
console.log('not loaded');
}
};
WebFont.load(WebFontConfig);
但这意味着浏览器在开始加载字体之前等待 css 文件的下载。css 只是几行代码,我不明白为什么我不能直接将它粘贴到 js 中。
有人知道如何实现吗?
最佳答案
这是不可能的; css 下载完成后开始检测。
关于javascript - 使用 WebFont 加载器时,如何硬编码 css?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16375554/