Prevent svg translation of fontawesome

不想你离开。 提交于 2019-11-29 04:37:30

If you'd like Font Awesome not to automatically replace <i> tags that look like icons with the corresponding <svg>s, you could change the configuration to disable autoReplaceSvg.

If you're loading via <script> tag, that might look like this (make sure to do the config before loading Font Awesome):

  <head>
    <script type="text/javascript">
      // Notice how this gets configured before we load Font Awesome
      window.FontAwesomeConfig = { autoReplaceSvg: false }
    </script>
    <script src="fontawesome.js"></script>
    <script src="fa-solid.js"></script>
  </head>

Or if you're building your own bundle and can access the config from within your own script you could do this:

import fontawesome from '@fortawesome/fontawesome'

fontawesome.config = { autoReplaceSvg: false }

I had the same issue, the icon tag was actually translated to SVG when I inspected the element.

The problem was I was loading fontawesome both via CSS and JS calls. When I removed the call to the JS lib and only called the CSS file, the icons rendered properly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!