Back

javascript - element ui , checkbox: 使用多层次的v-model的注意事项, v-model是个语法糖 v-model grammer sugar

发布时间: 2021-06-15 02:01:00

参考:https://segmentfault.com/q/1010000025126964/a-1020000025140872

<el-checkbox :model="foo" ... 是可以的

<el-checkbox :model="foo.bar" 是不行的,后者是一个深层次的调用。

这个时候,可以使用 <input type='checkbox'> 或者使用 <el-checkbox :value='foo.bar' @change='my_event' >

然后在 my_event中手动赋值。 

参考;https://forum.vuejs.org/t/what-is-the-syntactic-sugar-for-v-model-on-select-element/5912

v-model其实是个语法糖,

<input v-model="something"> is really just syntactic sugar for <input v-bind:value="something" v-on:input="something = $event.target.value">.

Back