VueJS computed elements

Spread the love

Computed elements, a noble idea I thought I had no use for. I do most my logic in methods. So, when I needed to, a method can modify the variable I would need on the page…

and then…

Today I was working on a stripe.com payment module, and randomly the payment form would not load. I needed to show the form conditionally if an element in the backend database was true. Well, that would hide the div.

What was the solution? The div became a v-if on a computed element. The computed element would check the API. So, now the page would load before computing, and that solved that.

Now that I wrapped my head around it, I think this would be better in many parts in my apps, and improve speed overall.