I know that the default behaviour of a object when we create new atributes for the same instance is that it reference the old, changing the properties.
I have something like this on my vue data:
export default {
data() {
return {
paragraph: {
text: "",
fontSize: 14,
key: "Paragraph",
align: "left"
}
}
},
methods: {
addParagraph() {
this.$set(this.paragraph, 'key', this.paragraph.key);
this.$set(this.paragraph, 'text', this.paragraph.text);
this.$set(this.paragraph, 'fontSize', this.paragraph.fontSize);
this.$set(this.paragraph, 'align', this.paragraph.align);
this.$store.commit("appendToDocument", this.paragraph)
},
alignment(option) {
this.paragraph.align = option;
}
}
everytime i click a button the data inside the paragraph changes and i want to pas the data to vuex store to add it to a json, so i can have a tree of paragraphs, the problem is, that everttime i create a new paragrapg it changes the values of my other paragraphs created before, is there a way to change it?