nuxt webfontloader
1.0.0
发行说明
nuxt-webfontloader添加为使用纱线或npm的依赖项nuxt-webfontloader添加到nuxt.config.js的modules部分 {
modules : [
'nuxt-webfontloader' ,
] ,
}nuxt.config.js : export default {
webfontloader : {
google : {
families : [ 'Lato:400,700' ] //Loads Lato font with weights 400 and 700
}
} ,
}nuxt.config.js头部删除旧样式表: export default {
head : {
link : [
// You don't need that line anymore!
{ rel : 'stylesheet' , href : 'https://fonts.googleapis.com/css?family=Lato:400,700' }
]
}
} 如果您想使用带有字体放置选项的Goggle Fonts,这是可能的。
但是,如果您只想添加一个字体家庭或多个字体家庭,则有很小的区别。
这里是一个示例,用于添加一个具有字体显示选项的字体族:
export default {
webfontloader : {
google : {
// Loads Open Sans font with weights 300 and 400 + display font as swap
families : [ 'Open+Sans:300,400,600&display=swap' ]
}
} ,
}在这里,添加具有字体显示选项的更多字体系列的示例:
export default {
webfontloader : {
// add Google Fonts as "custom" | workaround required
custom : {
families : [
'Open Sans:n3,n4' ,
'Roboto:n3,n7'
] ,
urls : [
// for each Google Fonts add url + options you want
// here add font-display option
'https://fonts.googleapis.com/css?family=Open+Sans:300,400&display=swap' ,
'https://fonts.googleapis.com/css?family=Roboto:300,700&display=swap'
]
}
} ,
} yarn install或npm install安装依赖项npm run dev启动开发服务器麻省理工学院许可证
版权(c)亚历山大·利希特(Alexander Lichter)