带表单的v-for循环未分配值

问题描述

我有一个错误

Cannot assign to read only property 'description' of object '#<Object>'

当尝试更改description的值时。

我有一组对象[{description,amount}]。它是从父组件传递的。我猜问题出在v-for循环中。为什么会出现此错误,我该如何解决

    props: {
        data: {
            type: Object,required: true,},data() {
        return {
            object: {...this.data.object},};
    },
            <template v-for="(item,index) in object.items">
                  <input v-model="item.description"/>

解决方法

好的,我已解决此问题。我深深地克隆了该对象,现在可以正常使用了。