29 lines
746 B
JavaScript
29 lines
746 B
JavaScript
//ReactDOM.render(<h1>Hello, world</h1>, document.getElementById('root'));
|
|
// 1.变量的使用
|
|
// 在JSX中嵌入表达是
|
|
// const name = 'Cuto'
|
|
// const e = <h1>Hello, {name}</h1>
|
|
// ReactDOM.render(e, document.getElementById('root'));
|
|
|
|
// 2.函数的使用
|
|
// function test(){
|
|
// return "handsome cuto!"
|
|
// }
|
|
// const e = <h1>Hello, {test()}</h1>
|
|
// ReactDOM.render(e, document.getElementById('root'));
|
|
|
|
|
|
// 3.防止xss注入
|
|
// const title = "<script>alert('111')</script>"
|
|
// const e = <h1>Hello, {title}</h1>
|
|
// ReactDOM.render(e, document.getElementById('root'));
|
|
|
|
|
|
const content = (
|
|
<div>
|
|
<h1>hello, cuto</h1>
|
|
<br/>
|
|
<p>Love cuto</p>
|
|
</div>
|
|
);
|
|
ReactDOM.render(content, document.getElementById('root')); |