当前位置 : 主页 > 编程语言 > java >

React尝试案例一

来源:互联网 收集:自由互联 发布时间:2022-10-26
React尝试案例二 ! DOCTYPE html html head meta charset = "UTF-8" / title Hello React ! / title ReactDOM . render ( h1 Hello , world ! / h1 , / / JSX document . getElementById ( 'example' ) ); / / JSX const element0 = h2 hello , react .


React尝试案例二

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>

ReactDOM.render(
<h1>Hello, world!</h1>,
// JSX
document.getElementById('example')
);


// JSX
const element0 = <h2>hello, react.</h2>
ReactDOM.render(
element0,
document.getElementById("mine")
)

const name = "huyuxuan"
const element1 = <h2>by, {name}</h2>
// render


ReactDOM.render(
element1,
document.getElementById("mine0")
)

</script>


</head>
<body>

<div id="example"></div>
<div id="mine">

</div>

<div id="mine0"></div>

</body>
</html>

<!--

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')
); -->


上一篇:React学习案例四
下一篇:没有了
网友评论