3👍
✅
@Potray answer is good. But it can be even shorter if you are using Babel with stage-3 (spread operator). Then you can copy all properties with that syntax
addParagraph() {
this.$store.commit("appendToDocument", { ...this.paragraph })
},
2👍
Try this:
addParagraph() {
var paragraph = {
key: this.paragraph.key,
text: this.paragraph.text,
fontSize: this.paragraph.fontSize,
align: this.paragraph.alignkey,
}
this.$store.commit("appendToDocument", paragraph)
},
Source:stackexchange.com