jsx 语法规范
一、插值語法 – {}
const str = 'hello react'; const VDOM = <h1>{str}</h1>; // 注意:是一對大括號 {} 和 Vue( {{}} ) 區分開二、給標簽添加類名 – className= "" | {}
/*css:.active {background-color: red;} */const VDOM = <h1 className="active">hello react</h1>;三、內聯樣式 – style={{ }}
const VDOM = <h1 style={{color: 'red', fontSize: '100px'}}>hello react</h1>;四、標簽必須閉合
<input type="text" /> <img src="" /> ...五、只能有一個根標簽
const VDOM = ( // 如果有很多標簽,推薦外面包一個小括號<div><h1 className="active">hello react</h1><input type="text" /></div> ); 創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
- 上一篇: Xshell 的基本使用
- 下一篇: 男孩读计算机好还是铁路学校好,中专学计算