当前位置:网站首页>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
边栏推荐
- Detailed explanation of Milvus 2.0 quality assurance system
- 计组 | 【七 输入/输出系统】知识点与例题
- Camtasia2022软件新增功能介绍
- 文件操作《二》(5000字总结篇)
- 面试百分百问到的进程,你究竟了解多少
- Shortcut keys (multiline)
- An essay on the classical "tear down the wall in thinking"
- Milvus 2.0 détails du système d'assurance de la qualité
- English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)
- Milvus 2.0 质量保障系统详解
猜你喜欢
ByteVCharts可视化图表库,你想要的我都有
Shell script -- shell programming specification and variables
Nacos + aspnetcore + Ocelot actual combat code
[pimf] openharmony paper Club - what is the experience of wandering in ACM survey
Dlib of face recognition framework
无线鹅颈麦主播麦手持麦无线麦克风方案应当如何选择
Grpc gateway based on Ocelot
Derivation of Σ GL perspective projection matrix
网络安全之渗透靶场实战详解
How to choose the wireless gooseneck anchor microphone and handheld microphone scheme
随机推荐
How to build tiktok user trust and drive fan growth
An essay on the classical "tear down the wall in thinking"
How to choose the wireless gooseneck anchor microphone and handheld microphone scheme
freeCodeCamp----shape_ Calculator exercise
正则过滤内网地址和网段
[registration] tf54: engineer growth map and excellent R & D organization building
Path environment variable
聊一聊浏览器缓存控制
Summary of common websites
STM32__ 03 - beginner timer
[problem solving] [show2012] random tree
Installing labellmg tutorial in Windows
RTKLIB 2.4.3源码笔记
Variable length parameter__ VA_ ARGS__ Macro definitions for and logging
BUG_ me
Use case execution of robot framework
Paging the list collection
杂文 谈谈古典的《拆掉思维里的墙》
PHP高效读大文件处理数据
拷贝构造函数 浅拷贝与深拷贝