DEV Community

Discussion on: (An Approach to) Vue.js Template Variables

 
blocka profile image
Avi Block

Hmmm...no you can't use a computed here. It's in a loop. That was the whole point here.

Thread Thread
 
pbastowski profile image
pbastowski • Edited

Indeed, you’re right. A normal computed wouldn’t have access to the v-for parameter here and a parametrized computed wouldn’t be cached.
If you need caching then you will need a different technique.
You could declare a data variable and then assign the v-for iterator to it, like I have shown in my example. In this way, a computed would have access to that data variable with the iterator’s value. Would this work for you?