问题描述
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"/>
解决方法
好的,我已解决此问题。我深深地克隆了该对象,现在可以正常使用了。