0👍
It’s doable but not elegant.
Basically, generate an object dynamically and merge it into computed
.
Here’s a simple example.
let dynamicComputed = {};
for (let i = 0; i < 3; i++) {
dynamicComputed[`message` + i] = {
get() {
// get operation
},
set() {
// set operation
}
};
}
export default {
computed: {
exampleComputed() {
return "example Computed values";
},
...dynamicComputed
}
};
Source:stackexchange.com