I have an array of objects called config, and a currentIdx property in my component. Then I found myself needing to do this:
computed: {
textStyle: function() {
return this.config[this.currentIdx].textStyle;
},
text: function() {
return this.config[this.currentIdx].text;
},
key: function() {
return this.config[this.currentIdx].key;
}
}
I tried replacing all functions with:
computed: {
...this.config[this.currentIdx]
}
It passed the compilation, but I got an error in the browser console. I think the problem is that computed requires functions, but the spread syntax (...) returns objects. So, my question is: Is there any way to reduce the repetition in this case?
Thanks!