【发布时间】:2018-12-24 23:20:51
【问题描述】:
我正在使用来自组件库的<Form/> 组件。该表单有一个提交按钮的子组件。
const loginForm = [
{
label: "Username",
required: true,
type: "text"
},
{
label: "Password",
required: true,
type: "password"
}
]
<LoginForm
width={{ xs: 12, md: 4 }}
autoComplete={false}
buttonDisabled={buttonDisabled}
buttonLabel="LOGIN"
fields={loginForm}
onChange={this.onChange}
onSubmit={data => login({ variables: data })}
/>
生成这个 html:
我想为按钮设置样式。希望做这样的事情:
const LoginForm = styled(Form)`
Button_StyledButton{
outline: black solid 10px;
}
`
主要针对表单,然后是子按钮组件。
这可以用样式化的组件来完成吗?
【问题讨论】:
-
请问您使用的是哪个组件库?
-
不幸的是它不是公开的
-
@ArunYokesh 我确实看到了那个帖子,但这是一个不同的用例。他们将子组件作为子组件传递。这里的区别是我试图定位的按钮元素是由父表单组件生成的。
-
你试过写
const LoginForm = styled(Form)` > Button_StyledButton ...吗?另外,Form元素是否使用了给它的className属性?
标签: javascript css reactjs styled-components