In a Vue component, I have a method like as below
methods: {
submitMethod() {
let objA = {
id: this.id,
this.anObject
}
}
}
It gives, Syntax Error: this is a reserved word.
how to use the object, which is defined in somewhere like data() or computed, in the object of the method in Vue.js?
One workaround is that, this.anObject can be assigned to local variable and use that variable inside objA as below
submitMethod() {
let anObject = this.anObject
let objA = {
id: this.id,
anObject
}
}
But, is there a way to use this.anObject directly inside objA?