简体   繁体   English

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

[英]how to import and use Fontello in vue/nuxt project

so i have my svg image which i want to convert it to icon using Fontello to convert and import it to my nuxt project.所以我有我的 svg 图像,我想使用 Fontello 将其转换为图标以转换并将其导入我的 nuxt 项目。 but the configuration doesn't seem to work但配置似乎不起作用

this is what in my nuxt.config.js file这是我的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 */
  ],
}

in my html page, i'm using在我的 html 页面中,我正在使用

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

and my css file,和我的 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;
}

the problem is the css file counldn't read font-family: "fontello";问题是 css 文件无法读取font-family: "fontello"; did i config it wrong?我配置错了吗?

Stumble on the same issue just tonight and searched how to do it, I tried your config and it works.. Have you also imported the font folder provided by fontello which contains the actual font?今晚偶然发现了同样的问题并搜索了如何做,我尝试了你的配置并且它有效..你是否还导入了 fontello 提供的包含实际字体的字体文件夹?

If you open the fontello.css file you will see the @font-face property with url reference to thos font files make sure the url is the right one (easiest solution is to import font and css folder from fontello.zip) so that your assets foolder looks something like that Assets - css - font - images如果您打开 fontello.css 文件,您将看到 @font-face 属性,其中包含对 thos 字体文件的 url 引用,请确保 url 是正确的(最简单的解决方案是从 fontello.zip 导入字体和 css 文件夹),以便您的资产傻瓜看起来像这样资产 - css - 字体 - 图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM