const name = 'Tony';
const element = <h1>Hello {name}!</h1>
Note 1:JSX中,引用变量直接用{},但ES6用${};
Note 2:把标签赋值给变量时,外面不用加引号
const element = React.createElement(
'h1',
{className: 'greeting'},
'Hello, world!'
);
const name = 'Tony';
const element = <h1>Hello {name}!</h1>
const element = React.createElement(
'h1',
{className: 'greeting'},
'Hello, world!'
);