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