Components and v-model

When writing a plug-in, many times the child component needs to actively modify the value of the parent component or bind it.
At this time, it seems inappropriate to use pure parent-child component communication. It is better to let the parent component not operate data too much by itself, otherwise it will not be like a responsible component. At this time, the v-model sub-component is needed: this.$emit('custom attribute', data.ids
)

Parent component: <z-select @custom attribute='method'/>

How to write v-model parent component:
insert image description here
bind a data
insert image description here

How to write data data
v-model subcomponent:

insert image description here

Structure
There are two values ​​in the model:{} in the subcomponent export default, prop means that I want to correspond to the variable of props, and event means an event. When I trigger the event cc, it will change the value of the parent component v-model.

insert image description here

Guess you like

Origin blog.csdn.net/weixin_43311271/article/details/103408182