v-modal是一个语法糖,真正的实现还是靠:
:value="value"
@input="e => value = e.target.value"
本质就是:bind="value"
与@change="value = $event.target.value"
的结合
<input type="text" :value="msg" @input="msg=$event.target.value"><br/>{{msg}}
Vue
会默认使用一个名为value
的prop
,已经名为input
的事件
为了避免不用的value
有不同的作用,可以使用下面的方式定义自己想要的v-modal
行为
model: {
prop: 'checked',
event: 'change'
}