Avoid mutating a prop directly since the value will be overwritten

前端 未结 11 891
被撕碎了的回忆
被撕碎了的回忆 2020-12-10 01:07

I have very common problem with upgrading to Vue 2.0

I am getting warning:

Avoid mutating a prop directly since the value will be overwritte

11条回答
  •  一整个雨季
    2020-12-10 01:58

    From Vue 2.3.0 on you can use the .sync modifier:

    Sample from https://vuejs.org/v2/guide/components-custom-events.html#sync-Modifier:

    
    

    and in your controller...

    this.$emit('update:title', newTitle)
    

提交回复
热议问题