Joh*_*hnC 7 webpack vue.js roboto vuetify.js
我有一个使用VUE CLI 3.x创建的Vue / Vuetify应用程序正在开发中,并且想在本地提供Roboto字体,而不是通过Google cdn。
有人通过webpack和vue cli生成的vuetify应用项目完成了此任务吗?
Syl*_*age 21
使用 Vue CLI 3 + Vuetify:
安装字体机器人
npm install --save typeface-roboto
Run Code Online (Sandbox Code Playgroud)
在public/index.html
,删除
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
Run Code Online (Sandbox Code Playgroud)
在src/App.vue
,添加
<style lang="sass">
@import '../node_modules/typeface-roboto/index.css'
</style>
Run Code Online (Sandbox Code Playgroud)
首先将软件包安装typeface-roboto
到您的项目中。
然后将其导入您的main.js / index.js / boot.js或任何其他内容:
import 'typeface-roboto/index.css';
Run Code Online (Sandbox Code Playgroud)
最后,更新,webpack.config.js
以允许在模块规则内使用字体文件类型,即:
module: {
rules: [
//other stuff
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, use: 'url-loader?limit=25000' }
]
},
Run Code Online (Sandbox Code Playgroud)
字体文件类型woff
,woff2
,eot
和ttf
。
归档时间: |
|
查看次数: |
2271 次 |
最近记录: |