in VueJS by
How do you create reactive objects?

1 Answer

0 votes
by
In version 3.0 you can create a reactive object with the reactive() API.

const reactiveState = reactive({
count: 0
 })
In version 2.6, you can create reactive objects with Vue.observable() global API.

const reactiveState = Vue.observable({
  count: 0
})
These observable objects can be used directly in computed properties and render functions.

const Demo = {
  render(h) {
    return h('button', {
      on: { click: () => { reactiveState.count++ }}
    }, `count is: ${state.count}`)
  }
}
...