首页 > 解决方案 > 如何根据我的链接地址添加字母?在反应

问题描述

在此处输入图像描述

如果我点击链接,我希望在文本旁边添加“#”符号。(例如“FUN”<--如果点击这个链接,在那个文本之后改变这个-->“#FUN”)我如何实现它?帮助我的天才这是我的jsx代码

// styled-components
const ShapScroll = styled.div``;
const ShapTexts = styled.div`
  font-size: 20px;
  width: fit-content;
`;
const ShapText = styled.span`
  margin-right: 14px;
  border-bottom: 2px solid
    ${(props) => (props.current ? "#191919" : "transparent")};
  transition: border-bottom 0.3s ease-in-out;
`;

// react return
     <ShapTexts>
            <ShapScroll>
              <ShapText
                current={pathname === "/covid19"}
              >
                <ShapLinks to="/covid19">코로나19</ShapLinks>
              </ShapText>
              <ShapText current={pathname === "/news"}>
                <ShapLinks to="/news">뉴스</ShapLinks>
              </ShapText>
              .
              .
              .
              <ShapText
                current={pathname === "/sports"}}
              >
                <ShapLinks to="/sports">스포츠&lt;/ShapLinks>
              </ShapText>
            </ShapScroll>
          </ShapTexts>

标签: reactjsreact-hooksstyled-componentshorizontal-scrolling

解决方案


推荐阅读