This time I will bring you a summary of Vue's two-way binding methods. What are theprecautionsfor Vue to implement two-way binding? The following is a practical case, let's take a look.
The above example is just a syntax sugar, which is expanded to:
text = e.target.value" />
This It is also a syntax sugar, peeled off it is:
dialogVisible = newVisible" />
my-dialog component when the visible changesthis.$emit('update:visible', newVisible)
That's it.
Vue allows self-definition of components after version 2.2.0's v-model, this leads to the need to consider different configurations of components when implementing v-model in JSX/rendering functions, which cannot always be the case (if the model of my-dialog component is { prop: 'visible', event: 'change' }):
{ render(h) { return h('my-dialog', { props: { value: this.dialogVisible }, on: { input: newVisible => this.dialogVisible = newVisible } }) } }
{ render(h) { return h('my-dialog', { props: { visible: this.dialogVisible }, on: { change: newVisible => this.dialogVisible = newVisible } }) } }
{ render(h) { return h('my-dialog', { model: { value: this.dialogVisible, callback: newVisible => this.dialogVisible = newVisible } }) } }
{ render() { return (this.dialogVisible = newVisible } }} /> ) } }
完善个人信息
尊姓大名?
完善个人信息
尊姓大名?
this.actual${PropName} = newValueor
this.sync${PropName}(newValue)to pass new data to the parent component.
Detailed explanation of the steps for vue to activate the current routing
nodejs generates QR code (the simplest)
The above is the detailed content of Summary of two-way binding methods in Vue. For more information, please follow other related articles on the PHP Chinese website!