简体   繁体   English

链接组件不适用于样式组件

[英]Link component not working with Styled Components

The style not working风格不行

const MenuOption = styled(Link)`
  font-size: 14px;
`;

Only using pseudo-class that styles its works仅使用为其作品设计样式的伪类

The better way is to Make a styled div or ul and then wrap it around link tag.更好的方法是制作一个样式化的divul ,然后将其包裹在link标签周围。 Maybe make a component for it.也许为它制作一个组件。

Example:例子:

const NavBarLinkDiv = styled.div`
//your styles
`;
    
export default const NavBarLink = ({children}) =>{
    return(<Link>
        <NavBarLinkDiv>{children} </NavBarLinkDiv>
        </Link>
    ) 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM