简体   繁体   English

Dojo 2-如何在Dojo 2应用程序中使用字体图标

[英]Dojo 2 - how to use font icons in Dojo 2 application

I need to use font icons in my application. 我需要在应用程序中使用字体图标。 Can anyone please help me in how to use the font icons in Dojo 2 application. 任何人都可以帮助我如何在Dojo 2应用程序中使用字体图标。

Thanks in advance 提前致谢

Dojo 2 (via @dojo/cli-build-app) will include fonts files that are referenced in CSS. Dojo 2(通过@ dojo / cli-build-app)将包含CSS中引用的字体文件。 For example defining the font like the following in CSS: 例如,在CSS中定义如下所示的字体:

@font-face {
    font-family: 'IconFont';
    src: url('./fonts/IconFont.eot');
    src: local('☺'), url('./fonts/IconFontwoff') format('woff'), url('./fonts/IconFont.svg') format('svg');
    font-weight: 400;
}

This will ensure that the build tool includes the actual font files in the built version of the app and then you can use them like normal. 这将确保构建工具在应用程序的构建版本中包含实际的字体文件,然后您可以像平常一样使用它们。

If you're interested with using something like Font Awesome from a CDN, here's an example of using that, where you simply use string values for the classes properties on the VDOM elements. 如果您对使用CDN中的Font Awesome之类的内容感兴趣,这里有一个使用示例,您只需在VDOM元素上的classes属性中使用字符串值即可。

https://codesandbox.io/s/3v0qx5lnnm https://codesandbox.io/s/3v0qx5lnnm

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

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