close

[Solved] Vue.js computed property not updating

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Vue.js computed property not updating in javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Vue.js computed property not updating Error Occurs

Today I get the following error Vue.js computed property not updating in javascript.

How To Solve Vue.js computed property not updating Error ?

  1. How To Solve Vue.js computed property not updating Error ?

    To Solve Vue.js computed property not updating Error I've ran into similar issue before and solved it by using a regular method instead of computed property. Just move everything into a method and return your ret. Official docs.

  2. Vue.js computed property not updating

    To Solve Vue.js computed property not updating Error I've ran into similar issue before and solved it by using a regular method instead of computed property. Just move everything into a method and return your ret. Official docs.

Solution 1

If your intention is for the computed property to update when project.classes.someSubProperty changes, that sub-property has to exist when the computed property is defined. Vue cannot detect property addition or deletion, only changes to existing properties.

This has bitten me when using a Vuex store with en empty state object. My subsequent changes to the state would not result in computed properties that depend on it being re-evaluated. Adding explicit keys with null values to the Veux state solved that problem.

I’m not sure whether explicit keys are feasible in your case but it might help explain why the computed property goes stale.

Solution 2

I’ve ran into similar issue before and solved it by using a regular method instead of computed property. Just move everything into a method and return your ret. Official docs.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment