当前位置:网站首页>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>边栏推荐
- STM32__05—PWM控制直流电机
- es面试题
- trading
- 研发中台拆分过程的一些心得总结
- Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
- AcWing 245. Can you answer these questions (line segment tree)
- es面試題
- Software testing learning notes - network knowledge
- Kibana操控ES
- Quality means doing it right when no one is looking
猜你喜欢

Actual battle of financial risk control - under Feature Engineering

How to hide the scroll bar of scroll view in uniapp

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

Infix expression to suffix expression (computer) code

query词权重, 搜索词权重计算

Query word weight, search word weight calculation
![[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)

AcWing 245. Can you answer these questions (line segment tree)
![[learn C and fly] 2day Chapter 8 pointer (practice 8.1 password unlocking)](/img/2e/8fe55393ccca6663d98c0b3dd9a146.png)
[learn C and fly] 2day Chapter 8 pointer (practice 8.1 password unlocking)

2022-2028 global deep sea generator controller industry research and trend analysis report
随机推荐
Software development life cycle -- waterfall model
Summary of some experiences in the process of R & D platform splitting
Software testing learning notes - network knowledge
【做题打卡】集成每日5题分享(第二期)
[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)
oracle创建只读权限的用户简单四步走
MongoDB非關系型數據庫
Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science
[pit] how to understand "parameter fishing"
研发中台拆分过程的一些心得总结
[reading notes] programmer training manual - practical learning is the most effective (project driven)
Connected block template and variants (4 questions in total)
Après le mariage
How to turn off the LED light of Rog motherboard
Use the open source project [banner] to achieve the effect of rotating pictures (with dots)
[learn C and fly] day 5 chapter 2 program in C language (Exercise 2)
[punch in questions] integrated daily 5-question sharing (phase II)
[road of system analyst] collection of wrong topics in enterprise informatization chapter
[staff] diacritical mark (ascending sign | descending sign B | double ascending sign x | double descending sign BB)
Cesium dynamic diffusion point effect