Vue.js technology reveals Learning (2) Vue instance implemented mounted

Vue we are by  $mount examples of ways to mount  vm the

$mount The method actually to call  mountComponent method, mountComponent the core is the first example of a rendering Watcher, in its callback function calls the  updateComponent method, called this method  vm._render Xiansheng method as virtual Node, the final call to  vm._updateupdate the DOM.

 

To instantiate a rendering Watcher, in its callback function calls the  updateComponent method

new Watcher(vm, updateComponent, noop, {
    before () {
      if (vm._isMounted) {
        callHook(vm, 'beforeUpdate')
      }
    }
  }, true /* isRenderWatcher */)
new new Watcher Watcher instantiated rendering
callHook (VM, 'beforeUpdate' ) callback updateComponent method


updateComponent method:
 updateComponent = () => {
      vm._update(vm._render(), hydrating)
    }

 

updateComponent Which method first calls the render method


 
 

Guess you like

Origin www.cnblogs.com/guangzhou11/p/11297996.html