Avoid mutating a prop directly since the value will be overwritten

前端 未结 11 892
被撕碎了的回忆
被撕碎了的回忆 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 02:04

    Fast solution if your prop is an object.

    You can avoid using $emit or getting that error by using Object.assign() in Javascript. This is going to work the same as v-model attribute.

    example:

    // Update the user
    Object.assign(this.userProp, user);
    

提交回复
热议问题