vue work?
Vue.component("base-checkbox", {
model: {
prop: "checked",
event: "change"
},
props: {
checked: Boolean
},
template: `
<input
type="checkbox"
v-bind:checked="checked"
v-on:change="$emit("change", $event.target.checked)"
>
`
})
<base-checkbox v-model="lovingVue"></base-checkbox>
above is a piece of code from the vue official document
there is a problem with the understanding of change change = "$emit ("change", $event.target.checked)"
. Here input listens for the change event with v-on, and when the change event is triggered, the execution of $emit triggers the change event again, doesn"t that make it a loop?