到达并且字体很棒

问题描述 投票:1回答:1

我试图使用React的font-awesome。我设法从https://fontawesome.com/how-to-use/on-the-web/using-with/react得到了stroopwafel图标的例子。它很好,但可能不那么有用。现在我想要包含一个更有用的图标: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'.

那么,我怎么知道图标的名称是什么?

reactjs font-awesome
1个回答
0
投票

所以这就是诀窍:

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

camelCase并没有pesking -

接下来当你使用它时你不应该拥有fa,而不是camelCase,那第二个-怎么样?来吧,保持那个!

<FontAwesomeIcon icon="exclamation-triangle"/>

混乱?是的,我当然这么认为......

© www.soinside.com 2019 - 2024. All rights reserved.