如何在vue / nuxt项目中导入和使用Fontello

时间:2020-02-19 02:17:14

标签: vue.js svg nuxt.js fontello

所以我有我的svg图像,我想使用Fontello将其转换为图标,以转换并将其导入到我的nuxt项目中。但配置似乎不起作用

这就是我的 nuxt.config.js 文件

head: {
  css: [
    '~/assets/css/main.css',
    '~/assets/css/animation.css',
    '~/assets/css/fontello.css',
    '~/assets/css/fontello-ie7.css',
    '~/assets/css/fontello-ie7-codes.css', /*if IE 7 */
  ],
}

在我的html页面中,我正在使用

<i @click="goToChat" class="the-icons demo-icon icon-chat menu ic-menu">&#xe800;</i>

和我的css文件

.demo-icon {
  font-family: "fontello";
  font-style: normal;
  font-weight: normal;
  speak: none;
  display: inline-block;
  text-decoration: inherit;
  width: 1em;
  margin-right: 0.2em;
  text-align: center;
  font-variant: normal;
  text-transform: none;
  line-height: 1em;
  margin-left: 0.2em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

问题是css文件无法读取font-family: "fontello";我是否配置错误?

1 个答案:

答案 0 :(得分:0)

就在今晚偶然发现相同的问题,并搜索了操作方法,我尝试了您的配置,它就可以了。 您是否还导入了fontello提供的包含实际字体的字体文件夹?

如果打开fontello.css文件,您将看到@ font-face属性,其中url指向thos字体文件,请确保该url是正确的(最简单的解决方案是从fontello.zip导入font和css文件夹)这样您的资产笨蛋看起来像这样 资产 -CSS -字体 -图片