覆盖面和字体超赞

时间:2018-09-07 10:01:10

标签: reactjs font-awesome

我正在尝试使用React的真棒字体。我设法使用stroopwafel图标从https://fontawesome.com/how-to-use/on-the-web/using-with/react获取了示例。很好,而且所有功能都没那么有用。现在,我想包括一个更有用的图标:the exclamation mark。但是,这里的命名标准似乎有些问题,因为当我尝试时:

import { fa-exclamation-triangle } from '@fortawesome/free-solid-svg-icons'

我得到:Syntax error: Unexpected token, expected ,

当我尝试删除那些讨厌的-

import { faexclamationtriangle } from '@fortawesome/free-solid-svg-icons'

我得到'@fortawesome/free-solid-svg-icons' does not contain an export named 'faexclamationtriangle'.

那么,我怎么知道图标的名字呢?

1 个答案:

答案 0 :(得分:0)

这就是诀窍:

import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'

camelCase且没有隐藏-

接下来,当您使用它时,您不应该使用fa,而不要使用camelCase,那么第二个-呢?继续保持那个!

<FontAwesomeIcon icon="exclamation-triangle"/>

令人困惑?是的,我肯定是这样...