当前位置:网站首页>Yyds dry goods inventory web components series (VII) -- life cycle of custom components
Yyds dry goods inventory web components series (VII) -- life cycle of custom components
2022-07-06 03:57:00 【Programming samadhi】
Preface
What is meant by ” Life cycle “? seeing the name of a thing one thinks of its function , The life cycle refers to the whole process of an object from its birth to its death , Of course , The specific stage division of the life cycle of different objects may be different .
When we use the front-end component framework , We all know that each component has its own life cycle , After defining the component life cycle , Developers can execute different code logic in different life cycles of components , So as to achieve the role of management components .
In order to make Custom Elements More flexible in use , It also has the ” Life cycle “ Callback function , It allows developers to define methods that can be executed at different stages of the component's life .
Custom Elements Life cycle division
stay Custom Elements In the constructor of , You can specify multiple different callback functions , They will be called at different times of the element's life :
connectedCallback
: When Custom Elements First inserted into document DOM when , Called .disconnectedCallback
: When Custom Elements From the document DOM When deleted in , Called .adoptedCallback
: When Custom Elements When moved to a new document , Called .attributeChangedCallback
: When Custom Elements increase 、 Delete 、 When modifying its properties , Called .
Be careful : The lifecycle callback function of a custom element is used in its constructor .
Use of lifecycle callback function
First look at the effect :
What needs to be noted here is :adoptedCallback The callback is only available when the custom element is moved to a new document ( It's usually iframe) It will be triggered only when it is in .
The code is as follows :
Conclusion
That's all Custom Elements A simple example of using the lifecycle callback function , I hope it helped you !
Custom Elements In the callback function of ,adoptedCallback There are few usage scenarios , This needs attention .
- ~
- The end of this paper , Thank you for reading !
~
Learn interesting knowledge , Make interesting friends , Create interesting souls !
Hello everyone , I am a 〖 The samadhi of programming 〗 The author of Hermit King , My official account is 『 The samadhi of programming 』, Welcome to your attention , I hope you can give me more advice !
边栏推荐
- mysql关于自增长增长问题
- Redis (replicate dictionary server) cache
- Oracle ORA error message
- Cf603e pastoral oddities [CDQ divide and conquer, revocable and search set]
- 自动化测试怎么规范部署?
- C#(二十七)之C#窗体应用
- 《2022年中国银行业RPA供应商实力矩阵分析》研究报告正式启动
- How does technology have the ability to solve problems perfectly
- How to standardize the deployment of automated testing?
- Record the pit of NETCORE's memory surge
猜你喜欢
Blue Bridge Cup - Castle formula
UDP reliable transport protocol (quic)
[adjustable delay network] development of FPGA based adjustable delay network system Verilog
Containerization Foundation
Chinese brand hybrid technology: there is no best technical route, only better products
Redis (replicate dictionary server) cache
Custom event of C (31)
Exchange bottles (graph theory + thinking)
20、 EEPROM memory (AT24C02) (similar to AD)
SSTI template injection explanation and real problem practice
随机推荐
JVM的手术刀式剖析——一文带你窥探JVM的秘密
/usr/bin/gzip: 1: ELF: not found/usr/bin/gzip: 3: : not found/usr/bin/gzip: 4: Syntax error:
Python book learning notes - Chapter 09 section 01 create and use classes
Ethernet port &arm & MOS &push-pull open drain &up and down &high and low sides &time domain and frequency domain Fourier
Cf603e pastoral oddities [CDQ divide and conquer, revocable and search set]
UDP reliable transport protocol (quic)
[analysis of variance] single factor analysis and multi factor analysis
Pytoch foundation - (2) mathematical operation of tensor
Serial port-rs232-rs485-ttl
In Net 6 CS more concise method
Custom event of C (31)
Crawler of explanation and application of agency theory
Ks008 SSM based press release system
TCP/IP协议里面的网关地址和ip地址有什么区别?
使用JS完成一个LRU缓存
80% of the diseases are caused by bad living habits. There are eight common bad habits, which are both physical and mental
记一次excel XXE漏洞
C (thirty) C combobox listview TreeView
[meisai] meisai thesis reference template
Ipv4中的A 、B、C类网络及子网掩码