【发布时间】:2021-12-31 07:26:54
【问题描述】:
我有以下链接:
<NavLink to={x.url} className={(x) = x.isActive ? 'active' : 'not-active' } >
<img src={`icon-default.svg`} /> // change from default.svg to active.svg
Link Text
</NavLink>
我的图标在 HTML 而不是 CSS,我想根据 isActive 调用不同的 img,是否可以在子元素(img 标记)上执行此操作?
react-router-dom": "^6.0.2"
谢谢
【问题讨论】:
标签: reactjs react-router react-router-dom