![](/img/trans.png)
[英]How to pass an object as props to a child Functional Component in React.js?
[英]how to give margin to a functional component in react.js?
这是功能组件返回的我的代码:
return (
<div className="card border-0 shadow " >
<div className="card-header">Update a Book</div>
<div className="card-body">
<form onSubmit={(e) => onUpdateContact(e)}>
<div className="form-group">
<TextField
id="outlined-helperText"
label="Enter The Name"
defaultValue={n}
onChange={(e) => setName(e.target.value)}
variant="outlined"
/>
</div>
<div className="form-group">
<TextField
id="outlined-helperText"
label="Enter The Isbn"
defaultValue={isb}
onChange={(e) => setIsbn(e.target.value)}
variant="outlined"
/>
</div>
<button className="btn btn-warning" type="submit">
Update Book
</button>
</form>
</div>
</div>
);
我想给它左边距....怎么做? 当我在<div className="card border-0 shadow " >
中输入边距作为属性时,它会给出错误
错误:
<div className="card border-0 shadow " margin=20px >
您可以使用style
属性:
<div className="card border-0 shadow" style={{margin: 20}} >
或者您可以通过 CSS 添加边距:
.card {
margin: 20px;
}
这是你需要的
<div style={{margin: '0 20px'}}>...Your content </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.