当前位置:网站首页>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
边栏推荐
- Zhongang Mining: Fluorite Flotation Process
- VLAN高级技术,VLAN聚合,超级Super VLAN ,Sub VLAN
- 扫码登录的原理你真的了解吗?
- Nodejs installation and environment configuration
- 批量制造测试数据的思路,附源码
- Do you really understand the principle of code scanning login?
- _ Mold_ Board_
- Read a blog, re understand closures and tidy up
- MySQL restores data through binlog file
- Shortcut keys (multiline)
猜你喜欢
随机推荐
Document operation II (5000 word summary)
Production environment——
Calculation formula related to tolerance analysis
批量制造测试数据的思路,附源码
◰GL-着色器处理程序封装
5-minute NLP: text to text transfer transformer (T5) unified text to text task model
◰ GL shader handler encapsulation
Website_ Collection
Camtasia2022软件新增功能介绍
Idea of batch manufacturing test data, with source code
Go language, array, string, slice
Installing labellmg tutorial in Windows
org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
Public variables of robotframework
Customize my_ Strcpy and library strcpy [analog implementation of string related functions]
Decimal format decimal / datetime conversion processing
loggie 源码分析 source file 模块主干分析
_ Mold_ Board_
Interface document yaml
Paging the list collection