Basic Use <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>hello</title> </head> <body> <div id="app"> </div> <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script> <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script> <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script> <script type="text/babel"> // Virtual dom const str = 'hello react' const vDom = <h1>{str}</h1> // const vDom = <pppp>hello react</pppp> //Convert the virtual dom into the real dom ReactDOM.render(vDom, document.getElementById("app")) </script> </body> </html> Two ways to create a virtual DOM <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>hello</title> </head> <body> <div id="app"> </div> <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script> <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script> <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script> <script> // The first pure js creation (generally not used) // Virtual dom const str = 'hello react' const vDom = React.createElement('h1', { id: 'myId' }, str) // const vDom = <pppp>hello react</pppp> //Convert the virtual dom into the real dom ReactDOM.render(vDom, document.getElementById("app")) // </script> </body> </html> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>hello</title> </head> <body> <div id="app"> </div> <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script> <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script> <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script> <script type="text/babel"> // The first pure js creation (generally not used) // [] ul li use forEach to implement var names = ['Zhang Fei', 'Guan Yu', 'Zhao Yun'] const ul = <ul> { names && names.map((name,index)=> <li key={index}> {name} </li> ) } </ul> ReactDOM.render(ul,document.getElementById("app")) // </script> </body> </html> Knowledge point expansion: React pwa configuration Add the plugin to the webpack configuration file const WorkboxWebpackPlugin = require('workbox-webpack-plugin') plugins: [ new MiniCssExtractPlugin({ filename: '[name].css' }), new WorkboxWebpackPlugin.GenerateSW({ clientsClaim:true, skipWaiting:true }) ], This is the end of this article about two ways to use react in React html. For more relevant content about using react in React html, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Two methods to implement Mysql remote connection configuration
>>: Linux centOS installation JDK and Tomcat tutorial
1. When the mobile terminal processes the list sl...
If you forget your MySQL login password, the solu...
According to data analysis company Net Market Sha...
1. dhtmlxTree dHTMLxTree is a feature-rich Tree M...
Preface Recently, a data was operated incorrectly...
To write a drop-down menu, click the button. The ...
In HTML pages, we sometimes need to automatically ...
1. Unzip to the location where you want to instal...
Table of contents Constructor new Operator Implem...
I have newly installed MySQL 5.7. When I log in, ...
I have always wanted to learn about caching. Afte...
Don’t introduce a front-end UI framework unless i...
If you use docker for large-scale development but...
Table of contents 1. Subquery definition 2. Subqu...
Preface I have been summarizing my front-end know...