你能帮我造型吗?我有这些按钮,但一次只能有一个变成蓝色(焦点),而不是同时有几个
我的组件是这样的......
import { Container, Content } from './styles';
function PressedButton({ children, ...rest }) {
const [pressed, setPressed] = useState(false);
return (
<Container>
<Content
type="button" {...rest}
pressed={pressed}
onFocus={() => setPressed(!pressed)}
>
{children}
</Content>
</Container>
);
}
PressedButton 的样式...
import styled from 'styled-components';
(...)
export const Content = styled.button`
(...)
//props
background: ${({ pressed }) => pressed ? `linear-gradient(#449fd8, #1b699a)`: '#2a2a2a'};
color: ${({ pressed }) => pressed ? '#fff': '#7d7d7d'};
我的问题呈现
在父母中是这样呈现的......
tags.forEach((tag) => {
let saida = <PressedButton onClick={() => handleTag(tag)}>{tag}</PressedButton>
至尊宝的传说
九州编程
相关分类