![](/img/trans.png)
[英]Using Joi and/or Yup for schema validation, is there a way to make a collection of properties required if any of the other properties are present?
[英]Is there any way of using the same properties as in the other const?
我有这两种格式化按钮的方法。 我可以在第二个常量中使用我在第一个常量中定义的相同属性而不将它们复制到常量中吗?
export const StyledButton = styled.button`
display: inline-block;
padding: 1rem 2rem;
background: var(--btn-bg-color);
color: var(--accent-color);
font-family: var(--font-secondary);
`;
export const StyledButton2 = styled.button`
border-radius: 5rem;
margin-left: 2rem;
border-color: transparent;
`;
声明一个 const 变量并将其分配给您要重复的模板字符串值。 然后使用 ${myVariable} 将其插入到每个按钮的模板字符串中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.