You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionVue(options){if(process.env.NODE_ENV!=='production'&&!(thisinstanceofVue)){warn('Vue is a constructor and should be called with the `new` keyword')}this._init(options)}initMixin(Vue)stateMixin(Vue)eventsMixin(Vue)lifecycleMixin(Vue)renderMixin(Vue)exportdefaultVue
exportfunctioninitGlobalAPI(Vue: GlobalAPI){// configconstconfigDef={}configDef.get=()=>configif(process.env.NODE_ENV!=='production'){configDef.set=()=>{warn('Do not replace the Vue.config object, set individual fields instead.')}}Object.defineProperty(Vue,'config',configDef)// exposed util methods.// NOTE: these are not considered part of the public API - avoid relying on// them unless you are aware of the risk.Vue.util={
warn,
extend,
mergeOptions,
defineReactive
}Vue.set=setVue.delete=delVue.nextTick=nextTickVue.options=Object.create(null)ASSET_TYPES.forEach(type=>{Vue.options[type+'s']=Object.create(null)})// this is used to identify the "base" constructor to extend all plain-object// components with in Weex's multi-instance scenarios.Vue.options._base=Vueextend(Vue.options.components,builtInComponents)initUse(Vue)initMixin(Vue)initExtend(Vue)initAssetRegisters(Vue)}
The text was updated successfully, but these errors were encountered:
这个vue源码阅读系列,参考着各路大神的文章学习,都是记录来自己看的,不太合适star了本blog的朋友们观看
Vue定义
src/core/instance/index.js
Vue实质上是一个
Function
实现的类,只能通过new Vue去实例化它为何不用ES6的class去实现呢?
因为下面有很多
xxxMixin
的函数调用,用于给Vue的prototype
上扩展一些方法,而这些扩展需要按照功能分散到各个模块中去实现,而不是在一个模块里实现所有,这些方式是class难以实现的。这样做的好处是非常方便代码的维护和管理
在
src/core/global-api/index.js
中还通过initGlobalAPI
方法给Vue对象扩展了一些全局的静态方法The text was updated successfully, but these errors were encountered: