![](/img/trans.png)
[英]I am trying to create a react website and add hooks in it but face this erros
[英]I am trying to create a box in React, and it is not working
這是我的代碼:
class Landing extends Component {
state = {
box: " width: 300px , height: 100px, border: 1px solid blue; ",
};
render() {
return <div className={this.state.box}>Hello</div>;
}
}
這個想法是“你好”應該在一個盒子里。
相反,我得到的是一個沒有框的 web 頁面,只有一個你好。
請幫忙。
將className
更改為style
,並將box
in 變為真實的 object。
class Landing extends Component {
state = {
box: {width: '300px', height: '100px', border: '1px solid blue'},
};
render() {
return <div style={this.state.box}>Hello</div>;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.