当前位置:网站首页>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>边栏推荐
- Special symbols in SAP ui5 data binding syntax, and detailed explanation of absolute binding and relative binding concepts
- Mathematics in Sinorgchem: computational geometry
- JS slow animation
- 结婚后
- QT uses sqllite
- 自定义组件的 v-model
- 批量检测url是否存在cdn—高准确率
- LFM signal denoising, time-frequency analysis, filtering
- The video number will not be allowed to be put on the shelves of "0 yuan goods" in the live broadcasting room?
- [reading notes] programmer training manual - practical learning is the most effective (project driven)
猜你喜欢

Vsocde has cli every time it is opened js
![[road of system analyst] collection of wrong topics in enterprise informatization chapter](/img/c4/0bb4823ca85c440b4e0587a91b2585.jpg)
[road of system analyst] collection of wrong topics in enterprise informatization chapter

The wave of layoffs in big factories continues, but I, who was born in both non undergraduate schools, turned against the wind and entered Alibaba

Which brand of running headphones is good? How many professional running headphones are recommended

SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding

Connected block template and variants (4 questions in total)

About DNS

Special symbols in SAP ui5 data binding syntax, and detailed explanation of absolute binding and relative binding concepts

Addition without addition, subtraction, multiplication and division (simple difficulty)

研发中台拆分过程的一些心得总结
随机推荐
The basic steps of using information theory to deal with scientific problems are
[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)
JVM面试篇
How to turn off the LED light of Rog motherboard
MongoDB非关系型数据库
Stack - es - official documents - filter search results
连通块模板及变式(共4题)
Addition without addition, subtraction, multiplication and division (simple difficulty)
Share the basic knowledge of a common Hongmeng application
Mongodb non relational database
The middle element and the rightmost element of the shutter
Jvm-01 (phased learning)
What are the characteristics of common web proxy IP
AcWing 245. Can you answer these questions (line segment tree)
2022低压电工考试题模拟考试题库模拟考试平台操作
How does proxy IP participate in the direct battle between web crawlers and anti crawlers
SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding
设置状态栏颜色
[JSON] gson use and step on the pit
Which brand of sports headset is better? Bluetooth headset suitable for sports