当前位置:网站首页>V-model of custom component
V-model of custom component
2022-07-02 02:45:00 【One plus one is not two】
vue Official website definition :
Two way binding
<input :value="something" @input="something = $event.target.value">
Grammatical sugar
<input v-model="something">
therefore
<custom-input v-model="something"></custom-input>
In custom components, it is equivalent to
<custom-input :value="something" @input="something = $event.target.value">
</custom-input>
Example
Parent component :
<template>
<el-form ref="form">
<el-form-item label=" department :">
<frame-select v-model="form.depidProp"></frame-select>
</el-form-item>
</el-form>
</template>
<script>
import frameSelect from './component/frameSelect.vue'
export default {
components: { frameSelect },
data() {
return {
form: {
depidProp:''
},
}
},
methods: { }
}
</script>Child components
<template>
<el-select v-model="modelValue" @change="changeOrgList">
<el-option v-for="item in orgLevelList"
:label="item.name" :value="item.name" :key="item.id">
</el-option>
</el-select>
</template>
<script>
export default {
props: {
//value name
modelValue: {
type: [String,Number],
default: ''
},
},
data() {
return {
orgLevelList: [{id:1,name:' Organization Department '},{id:2,name:' The personnel department '},{id:3,name:' Technology Department '}]
}
},
model: {
prop: 'modelValue',//value name
event: 'changeOrgList',// The method that the child component needs to register to update the parent component value
},
methods: {
changeOrgList(val) {
this.$emit('changeOrgList', val)
}
}
}
</script>边栏推荐
- 2022 low voltage electrician test question simulation test question bank simulation test platform operation
- CVPR 2022 | Dalian Institute of technology proposes a self calibration lighting framework for low light level image enhancement of real scenes
- Deployment practice and problem solving of dash application development environment based on jupyter Lab
- how to come in an investnent bank team
- [staff] the direction of the symbol stem and the connecting line (the symbol stem faces | the symbol stem below the third line faces upward | the symbol stem above the third line faces downward | the
- 【liuyubobobo-玩转Leetcode算法面试】【00】课程概述
- STM32__05—PWM控制直流电机
- Mongodb base de données non relationnelle
- es面試題
- Stack - es - official documents - filter search results
猜你喜欢

【liuyubobobo-玩转Leetcode算法面试】【00】课程概述

Share the basic knowledge of a common Hongmeng application

STM32__05—PWM控制直流电机

【读书笔记】程序员修炼手册—实战式学习最有效(项目驱动)

2022-2028 global aluminum beverage can coating industry research and trend analysis report
![[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)](/img/39/42b1726e5f446f126a42d7ac673dce.png)
[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)
![[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)](/img/8e/a86a9724251718d98ce172a6a96e53.png)
[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)

连通块模板及变式(共4题)

Systemserver service and servicemanager service analysis

Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
随机推荐
[JSON] gson use and step on the pit
Realize the code scanning function of a custom layout
Baohong industry | what misunderstandings should we pay attention to when diversifying investment
es面試題
大厂裁员潮不断,双非本科出身的我却逆风翻盘挺进阿里
What are the characteristics of common web proxy IP
What is the difference between an intermediate human resource manager and an intermediate economist (human resources direction)?
Questions d'entrevue
Start from scratch - Web Host - 01
[question 008: what is UV in unity?]
【OpenCV】-5种图像滤波的综合示例
C # use system data. The split mixed mode assembly is generated for the "v2.0.50727" version of the runtime, and it cannot be loaded in the 4.0 runtime without configuring other information
What is the principle of bone conduction earphones and who is suitable for bone conduction earphones
Deployment practice and problem solving of dash application development environment based on jupyter Lab
Summary of some experiences in the process of R & D platform splitting
[punch in questions] integrated daily 5-question sharing (phase II)
What is the function of the headphone driver
The number one malware in January 2022: lokibot returned to the list, and emotet returned to the top
CVPR 2022 | Dalian Institute of technology proposes a self calibration lighting framework for low light level image enhancement of real scenes
Vsocde has cli every time it is opened js