Within my Vue component, I am dealing with an array prop called selectedSuppliers
that consists of objects. My goal is to set up a data property named suppliers
and initialize it with the values from selectedSuppliers
. However, I do not want any modifications made to suppliers
to affect the original selectedSuppliers
array.
I attempted the following approach:
props: {
selectedSuppliers: {
type: Array,
required: true
},
},
data () {
return {
selected: [...this.selectedSuppliers],
}
}
Unfortunately, this method did not produce the desired outcome. Is there a correct way to assign an array value from a prop to a data property within Vue?