FrontendDeveloper.in

Vue.js question detail

How do you create reactive objects?

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}`)
}
}
Back to all Vue.js questions
Get LinkedIn Premium at Rs 399