赞
踩
const jsx = <div className='app'>
<h1>Hello React! 动态变化数据:{
count}</h1>
</div>
npm i react react-dom
<script src="./node_modules/react/umd/react.development.js"></script>
<script src="./node_modules/react-dom/umd/react-dom.development.js"></script>
<div id="root"></div>
<script>
// 参数1:元素名称,参数2:元素属性,参数3:元素的子节点
var title = React.createElement('h1',null,'Hello React')
//参数1:要渲染的react元素
//参数2:挂载点
ReactDOM.render(title,document.getElementById('root'))
</script>
npx create-react-app my-app
npm start
import React from 'react'
import ReactDOM from 'react-dom/client'
React.createElement()
方法创建 react 元素ReactDOM.render()
方法渲染 react 元素到页面中var title = React.createElement('h1',null,'Hello React!!!')
var root = ReactDOM.createRoot(document.getElementById('root'))
root.render(title)
var title = <h1>Hello JSX</h1>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。