当前位置:网站首页>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
边栏推荐
- Second week of postgraduate freshman training: convolutional neural network foundation
- Windows 安装 MySQL 5.7详细步骤
- Collation of ml.net related resources
- Cluster usage specification
- Cs4344 domestic substitute for dp4344 192K dual channel 24 bit DA converter
- Reading of false news detection papers (3): semi supervised content-based detection of misinformation via tensor embeddings
- [beauty of software engineering - column notes] 30 | make good use of source code management tools to make your collaboration more efficient
- [beauty of software engineering - column notes] 22 | how to do a good job in technology selection for the project?
- Cs5340 domestic alternative dp5340 multi bit audio a/d converter
- ML.NET相关资源整理
猜你喜欢

HC-SR04超声波测距模块使用方法和例程(STM32)

Mysql rownum 实现

Background management system platform of new energy charging pile

Lora opens a new era of Internet of things -asr6500s, asr6501/6502, asr6505, asr6601

深度学习(1):银行客户流失预测

(视频+图文)机器学习入门系列-第5章 机器学习实践

Simplefoc parameter adjustment 2- speed and position control

Intelligent shelf safety monitoring system

TCP——滑动窗口

Arduinoide + stm32link burning debugging
随机推荐
PostgreSQL manually creates hikaridatasource to solve the error cannot commit when autocommit is enabled
【Transformer】SegFormer:Simple and Efficient Design for Semantic Segmentation with Transformers
Simplefoc parameter adjustment 1-torque control
torch.Tensor.to的用法
BiSeNet v2
Huawei wireless device configuration uses WDS technology to deploy WLAN services
【学术相关】为什么很多国内学者的AI的论文复现不了?
HC-SR04超声波测距模块使用方法和例程(STM32)
Chapter contents of the romance of the Three Kingdoms
Stm32ff030 replaces domestic MCU dp32g030
A problem encountered in SQL interview
Dp4301-sub-1g highly integrated wireless transceiver chip
Collation of ml.net related resources
Background management system platform of new energy charging pile
Mysql rownum 实现
Time function in MySQL
Pnpm install appears: err_ PNPM_ PEER_ DEP_ ISSUES Unmet peer dependencies
commonjs导入导出与ES6 Modules导入导出简单介绍及使用
Some tools, plug-ins and software links are shared with you~
Ws2812b color lamp driver based on f407zgt6