FontAwesome Kit 图标没有条件渲染
我在网站上使用了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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论