当前位置:网站首页>1-3 components and modules
1-3 components and modules
2022-04-23 16:59:00 【Endless cake】
Components and modules
modular
1. Providing specific functions to the outside world js Program , It's usually a separate js file
2. Why should it be disassembled into modules : With the increase of business , The code is getting more complicated
3. Reuse js, simplify js, Provide js efficiency
Components
1. A collection of code and resources used to achieve local functional effects (html/css/js/image) etc.
2. Used to improve the reuse rate of code , Simplify the code , Improve operational efficiency
Functional component
What to pay attention to :
1. Component initial must be uppercase
2. Function must have a return value
3. Labels must be used when using
<div id='text'></div>
// Functional component
function Demo() {
// Here this yes undefined, because babel It turns on strict mode . In strict mode, it is forbidden to this Point to window
console.log(this);
return <h2>sjsoj</h2>;
}
ReactDOM.render(<Demo />, document.getElementById("text"));
/*
Yes ReactDOM.render after .
1.react Resolved component label , eureka Demo Components
2. Then it is found that the component is defined by the function , Subsequent call function , The virtual machine that will be returned DOM, Then it appears on the page
*/
版权声明
本文为[Endless cake]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230554519835.html
边栏推荐
- 正则过滤内网地址和网段
- PostgreSQL column storage and row storage
- [PROJECT] small hat takeout (8)
- Expression "func" tSource, object "to expression" func "tSource, object" []
- Variable length parameter__ VA_ ARGS__ Macro definitions for and logging
- VsCode-Go
- Detailed explanation of Milvus 2.0 quality assurance system
- Detailed explanation of Niuke - Gloves
- Shell script -- shell programming specification and variables
- MySQL master-slave replication
猜你喜欢
信息摘要、数字签名、数字证书、对称加密与非对称加密详解
Detailed explanation of Niuke - Gloves
[PROJECT] small hat takeout (8)
Go language, array, string, slice
RTKLIB 2.4.3源码笔记
昆腾全双工数字无线收发芯片KT1605/KT1606/KT1607/KT1608适用对讲机方案
Shell script -- shell programming specification and variables
TypeError: set_figure_params() got an unexpected keyword argument ‘figsize‘
Node access to Alipay open platform sandbox to achieve payment function
STM32__03—初识定时器
随机推荐
How to build tiktok user trust and drive fan growth
Paging SQL
freeCodeCamp----prob_ Calculator exercise
文件操作《二》(5000字总结篇)
PostgreSQL列存与行存
NVIDIA graphics card driver error
1-2 characteristics of nodejs
Tencent resolves the address according to the IP address
Blue Bridge Cup provincial road 06 -- the second game of the 12th provincial competition
Pseudo Distributed installation spark
Nacos + aspnetcore + Ocelot actual combat code
How vscode compares the similarities and differences between two files
Path environment variable
vscode如何比较两个文件的异同
groutine
Quick install mongodb
【解决报错】Error in v-on handler: “TypeError: Cannot read property ‘resetFields’ of undefined”
Detailed explanation of the penetration of network security in the shooting range
MySQL master-slave synchronization pit avoidance version tutorial
【PIMF】OpenHarmony啃论文俱乐部—在ACM Survey闲逛是什么体验