What Vue.observable does

Official example: https://cn.vuejs.org/v2/api/#Vue-observable
Vue.observable(object)
Parameters : {object}
Usage : Make an object responsive. Vue will use it internally to process the objects returned by the data function. The
returned objects can be directly used in rendering functions and computed properties, and will trigger corresponding updates when changes occur. It can also be used as a minimal cross-component state store for simple scenarios:

const state = Vue.observable({
    
     count: 0 })

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

Guess you like

Origin blog.csdn.net/u013994400/article/details/126123530