Vue源码解析

系列文章连接
主要记录本身开始学习Vue的一些源码阅读:基于2.5.8版本node

Vue-SourceCode 介绍了git

  • Vue构造函数如何来的,以及其上的属性/方法/原型方法/静态方法
  • new Vue(options)的过程发生了什么
  • vnode对象如何生成
  • vnode对象如何挂载到真实的DOM节点
  • …..

VueRouter-SourceCode介绍了github

  • VueRouter的插入,VueRouter的使用,VueRouter实例的生成
  • VueRouter实例对象上的matcher和history对象的建立
  • VueRouter中的Vue组件RouterLink和RouterView的源码实现

Vuex-SourceCode介绍了异步

  • Vuex的插入,Vuex的使用,Vuex.Store的实例生成
  • Vuex实例生成:ModuleCollection installModule resetStoreVM等核心建立store实例的时候实现
  • Vuex对象中的辅助函数 mapGetters. mapActions等的源码实现
  • Vuex.Store生成的实例对象commit(同步)和dispatch(异步)的源码实现与区别

对比VueRouter和Vuex函数

  • new VueRouter(options). new Vuex.Store(options) 中的options都支持route嵌套和module嵌套
  • route的嵌套,不管主路由仍是子路由,都映射到了matcher对象上
  • module的嵌套,不管主模块仍是子模块,actions getters mutations都映射到了store对象上,因此后面在任何子组件中均可以经过辅助函数获得modules中的getters actions mutations等
  • router-view组件根据matcher匹配到的组件进行渲染对应的组件
  • 辅助函数能够在各个组件中获取到store实例对象上的actions. getters. mutations等;
相关文章
相关标签/搜索