Tooblippe
Tooblippe

Reputation: 3711

Use Vue computed property in more than one place but only calculate once

How can I use a Vue computed property in more than once place but only make the computed property function run only once and not once for every single time that I use it?

I am using the computed function output in 4 places, this makes the function call to the computed property run 4 times!

Upvotes: 0

Views: 852

Answers (1)

etischenko
etischenko

Reputation: 107

Computed properties are actually cached in Vue as the documentation says:

computed properties are cached based on their reactive dependencies. A computed property will only re-evaluate when some of its reactive dependencies have changed.

Maybe we can figure out what is the problem if you provide a code sample

Upvotes: 1

Related Questions