当前位置:网站首页>Component transfer participation lifecycle
Component transfer participation lifecycle
2022-07-29 08:21:00 【Ice eyes JS】
Catalog
1. Receive parameters and define default values
3. Before and after the update
4. Before and after destruction
One · Component parameters
1. Definition and use
//CounterCom.vue
<template>
<button>1</button>
</template>
App.vue
01 Import
import CounterCom from './components/CounterCom.vue'02 register
components:{CounterCom}03 Use
<CounterCom></CounterCom>
<counter-com></counter-com>2. Father's son
Use props The array passed from parent to child is read-only ( Default value , Read display ) It can't be modified
App.vue In file
<CounterCom :num="10">
CounterCom.vue In the component
1. Receive parameters and define default values
props:{
"num":{type:Number,default:1}
}2. Using parameter num
data(){
return {counter:this.num}
}3. Son father
Events used $emit
//CounterCom.vue
<button @click="counter++; $emit('counterchange',counter)">
// App.vue
<CounterCom @counterchange="n=$event">
$emit( Event name , Event value ) Send an event , Event name (counterchange) And event values (counter) Is custom
$event Fixed writing , Event value (counterchange Event value , It is also a sub component $emit Second parameter of )
Two · Life cycle
1. Concept
Each component goes through a series of specific processes from creation to destruction , Called life cycle
The callback function executed by the process is called the life cycle hook function
2. effect
After creation launch ajax request
Operation after mounting dom
Add event listener
Remove interval calls before destruction , Event monitoring
explain : Not every life cycle must use
3. Life cycle 8 individual
1. Before and after creation
beforeCreate Before creation :
characteristic : Yes this, No, data And methods Method
created After creation
characteristic : Yes data, No, $el,dom node
use :ajax request , Timer , Event monitoring
2. Before and after mounting
beforeMount Before mounting
characteristic : Yes $el , The data is not rendered
mounted After mounting
characteristic : Yes dom node , Data is also rendered
use : Operation node ,ajax request
3. Before and after the update
beforeUpdate Before updating
characteristic : Will execute many times , Data update ,dom Node not updated
updated Updated completely
characteristic : Will execute many times , Data update ,dom Nodes are also updated
4. Before and after destruction
beforeDestroy Before destruction
characteristic : Data can be updated , The view is no longer updated
use : Remove event monitoring , Stop timer
destroyed Destroyed
characteristic : No, this, Switch views with vue The connection of examples
边栏推荐
- Reading of false news detection papers (3): semi supervised content-based detection of misinformation via tensor embeddings
- 阿里巴巴政委体系-第三章、阿里政委与文化对接
- Compatible with cc1101/cmt2300-dp4301 sub-1g wireless transceiver chip
- STM32 MDK (keil5) contents mismatch error summary
- 110道 MySQL面试题及答案 (持续更新)
- 为了速率创建线程池,启动核心线程
- Charging pile charging technology new energy charging pile development
- 简易计算器微信小程序项目源码
- Inclination monitoring solution of Internet of things
- Simplefoc parameter adjustment 1-torque control
猜你喜欢

DAC0832 waveform generator based on 51 single chip microcomputer

Stm32ff030 replaces domestic MCU dp32g030

Ws2812b color lamp driver based on f407zgt6

Simplefoc+platformio stepping on the path of the pit

Node: file write data (readfile, WriteFile), two modes: overwrite and increment

Cs5340 domestic alternative dp5340 multi bit audio a/d converter

BiSeNet v2
![[beauty of software engineering - column notes] 28 | what is the core competitiveness of software engineers? (next)](/img/c1/49b4610c483933442fb96b8e3f5315.png)
[beauty of software engineering - column notes] 28 | what is the core competitiveness of software engineers? (next)

随机抽奖转盘微信小程序项目源码

数仓分层设计及数据同步问题,,220728,,,,
随机推荐
Node: file write data (readfile, WriteFile), two modes: overwrite and increment
【Transformer】SegFormer:Simple and Efficient Design for Semantic Segmentation with Transformers
深度学习(1):银行客户流失预测
Back up Google or other browser plug-ins
【Transformer】ATS: Adaptive Token Sampling For Efficient Vision Transformers
torch.nn.functional.one_ hot()
The difference between torch.tensor and torch.tensor
Simplefoc parameter adjustment 1-torque control
Unity multiplayer online framework mirror learning record (I)
数字人民币时代隐私更安全
SQL 面试碰到的一个问题
Stm32ff030 replaces domestic MCU dp32g030
Preparation of SQL judgment statement
Ws2812b color lamp driver based on f407zgt6
Proteus simulation based on msp430f2491
Second week of postgraduate freshman training: convolutional neural network foundation
Phy6252 is an ultra-low power Bluetooth wireless communication chip for the Internet of things
Lora opens a new era of Internet of things -asr6500s, asr6501/6502, asr6505, asr6601
Unicode私人使用区域(Private Use Areas)
Mysql rownum 实现