当前位置:网站首页>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>
边栏推荐
- Cesium dynamic diffusion point effect
- Jointly developed by nailing, the exclusive functions of glory tablet V7 series were officially launched
- 连通块模板及变式(共4题)
- How to run oddish successfully from 0?
- 2022-2028 global soft capsule manufacturing machine industry research and trend analysis report
- Oracle creates a user with read-only permission in four simple steps
- 【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表
- 【无标题】
- How to hide the scroll bar of scroll view in uniapp
- JVM面试篇
猜你喜欢
Pytest testing framework
Multi threaded query, double efficiency
连通块模板及变式(共4题)
Missing numbers from 0 to n-1 (simple difficulty)
Face++ realizes face detection in the way of flow
QT implementation interface jump
[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)
Software development life cycle -- waterfall model
STM32__ 05 - PWM controlled DC motor
【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表
随机推荐
The middle element and the rightmost element of the shutter
Questions d'entrevue
What are the characteristics of common web proxy IP
How to run oddish successfully from 0?
CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决
Jointly developed by nailing, the exclusive functions of glory tablet V7 series were officially launched
多线程查询,效率翻倍
JVM面试篇
DNS domain name resolution
2022-2028 global manual dental cleaning equipment industry research and trend analysis report
Analysis of FLV packaging format
[learn C and fly] 2day Chapter 8 pointer (practice 8.1 password unlocking)
JVM interview
大厂裁员潮不断,双非本科出身的我却逆风翻盘挺进阿里
2022-2028 global military computer industry research and trend analysis report
QT uses sqllite
Infix expression to suffix expression (computer) code
Share the basic knowledge of a common Hongmeng application
how to come in an investnent bank team
query词权重, 搜索词权重计算