How to solve [Vue warn]: Avoid mutating a prop directly since the value will be overwritten on vue.js 2?

后端 未结 3 973
北海茫月
北海茫月 2020-12-20 20:51

My view is like this :

... ...
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-20 21:28

    You need to make the computed with a getter and a setter and then use $emit to update the prop e.g:

        computed: {
            starValue:{ 
                get:function () {
                    return this.temp_value
                },
                set: function(newValue){
                    // $emit is the correct way to update props:
                    this.$emit('update:value', newValue);
                }
            }
        }
    

提交回复
热议问题