:value.syc和this.$emit('update:value', val);一起
v-model="showAlarm"和this.$emit('update:value', val);一组
<history-alarm-dialog v-if="showAlarm" :value.sync="showAlarm"></history-alarm-dialog> <el-dialog v-dialog-drag :modal="false" :visible.sync="dialogVisible" title="历史事件" width="1200px"> props: { value: Boolean }, data: function(){ }, computed: { dialogVisible: { get: function() { return this.value; }, set: function(val) { this.$emit('update:value', val); } } },
<history-alarm-dialog v-if="showAlarm" v-model="showAlarm"></history-alarm-dialog> dialogVisible: { get: function() { return this.value; }, set: function(val) { this.$emit('input', val); //this.$emit('update:value', val); } }
v-model 在内部为不同的输入元素使用不同的属性并抛出不同的事件: text 和 textarea 元素使用 value 属性和 input 事件; checkbox 和 radio 使用 checked 属性和 change 事件; select 字段将 value 作为 prop 并将 change 作为事件。