VueJS change v-model variable from child

前端 未结 2 1179
灰色年华
灰色年华 2021-01-21 22:32

I\'m trying to change the v-model of a component by the parent component most I\'m not getting.

In the parent component I have a showProgress v

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-21 22:52

    To enable usage of v-model by the parent, you have to define a value prop in the child and use it.

    
    
    

    This way, when you use:

    
    

    ...the value inside progress-modal will have the value of parent's showProgress.


    Keeping it named show

    To use other internal name instead of value you can declare the model option in the component.

    
    
    

提交回复
热议问题