当前位置:网站首页>1-2 JSX syntax rules
1-2 JSX syntax rules
2022-04-23 16:59:00 【Endless cake】
JSX Rule of grammar
- Define the virtual DOM When , Be sure not to use quotation marks .
- In the label Js When you use grammar {}.
- The class name of the style must be className
- The inline style should use {key:value} Write in a format
- fictitious DOM There must be only one root tag
- Label must be closed
- Label initials
(1) If it starts with a lowercase letter , Then change the label to A fellow html The elements in , if html There is no such label in the , False report .
(2) If it starts with a capital letter ,React Just render the corresponding components , If the component is not defined , False report .
Here's the exercise code :
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>react</title>
<style>
.title {
background-color: orange;
width: 200px;
}
</style>
</head>
<body>
<div id="text"></div>
<script src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
<!-- load Babel -->
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<script type="text/babel">
// Create virtual DOM
const myId = "aguigu";
const myDate = "HeLLO WORLD";
const VDOM = (
<div>
<h2 className="title" id={myId.toLowerCase()}>
<span style={
{ color: "white", fontSize: "29px" }}>
{myDate.toLowerCase()}
</span>
</h2>
<input type="text" />
</div>
);
// Rendering virtual DOM To page
ReactDOM.render(VDOM, document.getElementById("text"));
</script>
</body>
</html>
版权声明
本文为[Endless cake]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230554519876.html
边栏推荐
- 【PIMF】OpenHarmony啃论文俱乐部—在ACM Survey闲逛是什么体验
- File upload and download of robot framework
- TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘
- org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
- MySQL modify master database
- Error in v-on handler: "typeerror: cannot read property 'resetfields' of undefined"
- STM32__03—初识定时器
- groutine
- Installing labellmg tutorial in Windows
- DDT + Excel for interface test
猜你喜欢
SQL database
Project framework of robot framework
On lambda powertools typescript
STM32__03—初识定时器
CentOS MySQL multi instance deployment
New project of OMNeT learning
Nodejs installation and environment configuration
Kunteng full duplex digital wireless transceiver chip kt1605 / kt1606 / kt1607 / kt1608 is suitable for interphone scheme
英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
Nacos + aspnetcore + Ocelot actual combat code
随机推荐
无线鹅颈麦主播麦手持麦无线麦克风方案应当如何选择
Paging the list collection
Shell脚本——Shell编程规范及变量
How to implement distributed locks with redis?
English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)
_ Mold_ Board_
[pimf] openharmony paper Club - what is the experience of wandering in ACM survey
Generate random numbers with high quality and Gaussian distribution
Deepinv20 installation MariaDB
杂文 谈谈古典的《拆掉思维里的墙》
About stream flow, write it down briefly------
Shortcut keys (multiline)
Production environment——
DDT + Excel for interface test
freeCodeCamp----prob_ Calculator exercise
拷贝构造函数 浅拷贝与深拷贝
New keyword learning and summary
Installation and management procedures
Go language, array, string, slice
MySQL master-slave synchronization pit avoidance version tutorial