1. vue
(function (global, factory) { //根据当前环境中用的ADM或COMMONJS格式的模块规范或者未用模块管理规范,将Vue(函数)对象返回给对应变量属性(或全局变量), typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.Vue = factory()); }(this, (function () { 'use strict'; ..... return Vue$3; }) ));
1.立即执行函数
(function(global,factory){
}(this,(...)) )
将this和vue的构建函数传入匿名函数,根据当前环境进行vue初始化,如果是ADM模块管理下则传入define函数,Commonjs模块管理输出vue函数给module.exports,否则直接挂在全局变量上。
2.factory()
初始化Vue框架。
2.1 cached(fn)
cached(fn):缓存函数,提供fn缓存处理函数,然后存在内部变量cache中。
2.2 资源类型
//资源类型 var ASSET_TYPES = [ 'component',//组件 'directive',//指令 'filter'//过滤器 ]; //生命周期内的函数钩子 var LIFECYCLE_HOOKS = [ 'beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUpdate', 'updated', 'beforeDestroy', 'destroyed', 'activated', 'deactivated', 'errorCaptured' ];