gpt4 book ai didi

javascript - 如何在 VueJS 应用程序中使用 Google Web 字体?

转载 作者:行者123 更新时间:2023-11-30 19:41:03 26 4
gpt4 key购买 nike

我确实找到了这个插件 https://github.com/gabiseabra/google-fonts-webpack-plugin

更新了使用入门工具包生成的 babel.config.js:

const GoogleFontsPlugin = require('google-fonts-webpack-plugin')

module.exports = {
presets: [
'@vue/app',
],
plugins: [
new GoogleFontsPlugin({
fonts: [
{ family: 'Inconsolata' },
{ family: 'Oswald' },
],
/* ...options */
}),
],
};

将字体添加到#app

<template>
<div id="app">
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<router-view/>
</div>
</template>

<style lang="scss">
#app {
font-family: 'Inconsolata', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
#nav {
padding: 30px;
a {
font-weight: bold;
color: #2c3e50;
&.router-link-exact-active {
color: #42b983;
}
}
}
</style>

但是字体还是宋体:

enter image description here

https://fonts.google.com/specimen/Inconsolata?selection.family=Inconsolata

最佳答案

刚刚弄明白了,我必须像这样导入它:

<style lang="scss">
@import url('https://fonts.googleapis.com/css?family=Inconsolata|Oswald');
#app {
font-family: 'Inconsolata', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
#nav {
padding: 30px;
a {
font-weight: bold;
color: #2c3e50;
&.router-link-exact-active {
color: #42b983;
}
}
}
</style>

关于javascript - 如何在 VueJS 应用程序中使用 Google Web 字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55403412/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com