[TOC] > [教程](https://zh-hans.reactjs.org/docs/introducing-jsx.html) ## 插入变量 ``` const name = 'Josh Perez'; const element = <h1>Hello, {name}</h1>; ReactDOM.render( element, document.getElementById('root') ); ``` ## 插入函数 ``` function formatName(user) { return user.firstName + ' ' + user.lastName; } const user = { firstName: 'Harper', lastName: 'Perez' }; const element = ( <h1> Hello, {formatName(user)}! </h1> ); ReactDOM.render( element, document.getElementById('root') ); ``` ### JSX 特定属性 用大括号包裹 js代码 `const element = <img src={user.avatarUrl}></img>; `