S
S
Sergey Sokolov2019-02-11 21:10:04
Vue.js
Sergey Sokolov, 2019-02-11 21:10:04

Is a computed property reactive with get() and set()?

The Vue component has a computed property that needed to add a setter as well . But for some reason the color of the button depending on this property does not change after changing it. Reactivity is broken.
Inside the methods, we are working with a property from an external module.
Is that how it's supposed to be or did I screw up somewhere?
Example:

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex, 2019-02-11
@sergiks

your state object is not reactive. in order for it to be such, it must either be initialized in data:

const comp = Vue.component('comp', {
  ...
  data() {
  	return state
  },
  ...
})

or do this:
const state = Vue.observable({ z: false });
const comp = Vue.component('comp', {
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question