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)