FontAwesome Kit 图标没有条件渲染

发布于 2025-01-19 14:13:07 字数 700 浏览 2 评论 0原文

我在网站上使用了Fontawesome套件,并且没有显示任何图标的任何问题。

但是,现在我只是尝试执行以下操作:

const [sort, setSort] = useState(true)

<i class={sort ? "fa-regular fa-angle-down" : "fa-regular fa-angle-up"}></i>

或者

{sort ? <i class="fa-regular fa-angle-down"></i> : <i class="fa-angle fa-angle-up"></i>}

我可以从console.log中看到,并且如果我什至做sort.tostring()对图标所在的位置,当我单击按钮时,状态正在发生变化。但是,在这种情况下,没有fa-angle fa-chevron-up图标的渲染。它只是一直显示fa-angle fa-angle-down图标。如果我将图标更改为某些文本,例如:

{sort ? "foo" : "bar"}

它在两者之间更改。但不是fontawesome图标。

我是做错了什么,还是...?

I am using the FontAwesome kit on my website, and I'm not having any issues displaying any icons.

However, now I just tried to do the following:

const [sort, setSort] = useState(true)

<i class={sort ? "fa-regular fa-angle-down" : "fa-regular fa-angle-up"}></i>

or

{sort ? <i class="fa-regular fa-angle-down"></i> : <i class="fa-angle fa-angle-up"></i>}

I can see from console.log and if I even do sort.toString() right where the icons are, that the state is changing when I click my button. However, in this case there is no rendering of the fa-angle fa-chevron-up icon. It just keeps showing the fa-angle fa-angle-down icon all the time. If I change the icons to some text, e.g:

{sort ? "foo" : "bar"}

Then it changes between the two. But not FontAwesome icons.

Am I doing something wrong, or...?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文