I have a construction like this:
<div v-for="item in items">
<p>{{ f1(item).k1 }}</p>
<p>{{ f1(item).k2 }}</p>
<p>{{ f2(item).k3 }}</p>
<p>{{ f2(item).k4 }}</p>
</div>
where f1 and f2 are the component's methods that return objects with the fields k1, k2, k3, k4. In this example the methods are called as many times as many keys I need in the template, that can be expensive.
Is there a way to store the results of calculations into variables v1 and v2 to prevent multiple calls?
I found a solution for one temporary variable:
<div v-for="item in items" :set="v1 = f1(item)">
<p>{{ v1.k1 }}</p>
<p>{{ v2.k2 }}</p>
</div>
but I couldn't generalize it for the case with two variables elegantly. Also I met the solutions to create a different component for the tag with v-for instead of div I used, it seems to be too complicated and bulky.
f1andf2return objects withk1throughk4properties?f1andf2are two completely different functions that I do not want to merge into one.