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
This article shares with you the graphic tutorial...
Docker includes three basic concepts: Image: A Do...
During the development activity, I encountered a ...
Detailed explanation of mysql count The count fun...
Solution: Bind the click event to the audio compo...
Socket option function Function: Methods used to ...
What you learn from books is always shallow, and ...
1. Introduction By enabling the slow query log, M...
1. Purchase a server In the example, the server p...
[LeetCode] 175.Combine Two Tables Table: Person +...
As shown above, the navigation is fixed at the to...
1. Time types are divided into: 1. Network time (...
In Node.js, a .js file is a complete scope (modul...
Using UNION Most SQL queries consist of a single ...
0. Preparation: • Close iTunes • Kill the service...