当前位置: 首页 > news >正文

珠海市官网网站建设品牌东莞制作网站的联系方式

珠海市官网网站建设品牌,东莞制作网站的联系方式,专门做网页设计网站,网易企业邮箱怎么认证今天我们来分析使用new Vue() 之前研究时,只是说是在创建一个实例。并没有深入进行研究 在vue的源码中找下Vue的构造函数 function Vue(options) {if (!(this instanceof Vue)) {warn$2(Vue is a constructor and should be called with the new keyword);}this.…

今天我们来分析使用new Vue()

之前研究时,只是说是在创建一个实例。并没有深入进行研究

在vue的源码中找下Vue的构造函数

function Vue(options) {if (!(this instanceof Vue)) {warn$2('Vue is a constructor and should be called with the `new` keyword');}this._init(options);}

if判断语句是指,需要用new 关键字来构造实例对象

后面就是 this._init(options)  调用了_init方法,参数是options

找到_init(options)方法

接下来我们逐句分析

Vue.prototype._init = function (options) {// 1. 定义变量对象vm  后续需要给vm添加属性,再将vm作为参数调用一系列函数const vm = this;// a uid// 2. vm添加_uid属性, 自增vm._uid = uid++;let startTag, endTag;// 3. istanbul ignore if 是一个注释指令,用于在代码覆盖率工具 Istanbul 中标记某段代码,以便在生成代码覆盖率报告时忽略该段代码的覆盖率计算// 从英文名猜下是关于performance性能的,暂时先不管它。后续有遇到再继续研究/* istanbul ignore if */if (config.performance && mark) {startTag = `vue-perf-start:${vm._uid}`;endTag = `vue-perf-end:${vm._uid}`;mark(startTag);}// a flag to mark this as a Vue instance without having to do instanceof// check// 4. vm添加_isVue属性vm._isVue = true;// avoid instances from being observed// 5. vm添加__v_skip属性vm.__v_skip = true;// effect scope// 6. vm添加_scope属性 _scope是new EffectScope()vm._scope = new EffectScope(true /* detached */);// #13134 edge case where a child component is manually created during the// render of a parent component// 7. vm._scope设置属性vm._scope.parent = undefined;vm._scope._vm = true;// merge options// 8. 核心代码,对于入参options进行判断// initInternalComponent(vm, options)  这个我们暂时还没有遇到过,先跳过// 或者mergeOptions()     一会儿研究if (options && options._isComponent) {// optimize internal component instantiation// since dynamic options merging is pretty slow, and none of the// internal component options needs special treatment.initInternalComponent(vm, options);}else {vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);}/* istanbul ignore else */// 9. initProxy(vm)  一会儿研究{initProxy(vm);}// expose real self// 10. vm添加_self属性vm._self = vm;// 11. 调用一堆方法 一会儿研究initLifecycle(vm);initEvents(vm);initRender(vm);callHook$1(vm, 'beforeCreate', undefined, false /* setContext */);initInjections(vm); // resolve injections before data/propsinitState(vm);initProvide(vm); // resolve provide after data/propscallHook$1(vm, 'created');/* istanbul ignore if */// 12. 感觉又是跟性能有关的内容if (config.performance && mark) {vm._name = formatComponentName(vm, false);mark(endTag);measure(`vue ${vm._name} init`, startTag, endTag);}// 13.如果vm.$options有el参数,后续执行了$mount挂载if (vm.$options.el) {vm.$mount(vm.$options.el);}};

http://www.yayakq.cn/news/120619/

相关文章:

  • 跟建设通一样的网站外贸跟单的流程
  • 撸撸撸做最好的导航网站政务版企业微信app下载安装
  • 电话营销网站推广浦东新区建设局官方网站
  • 部门网站建设情况汇报怎么把图片做成链接形式
  • 设计素材网站有哪些平台东莞做网站的公司有哪些
  • 网站定制营销的过程服务专业的网站建设服务
  • 做微信的网站叫什么wordpress交流插件
  • 衡水哪家制作网站好网站模块设计软件
  • 巩义移动网站建设网站源代码上传都需要怎么做
  • 沈阳做网站一诚金网络专业如何网上外贸接单
  • 做论坛网站需要哪些前置审批做网站注意事项
  • 湖南省建设信息网站电子商务网站建设技能实训答案
  • 网站建设冖金手指花总十四设计在线好看
  • 赣州市网站建设公司华为网络工程师培训费用
  • 如何设计公司官网站易语言怎么用网站做背景音乐
  • 长沙网站建设 599在线免费开网站
  • 网站建设好了怎么发布平台搭建与拆除
  • 网站运营做网页设计wordpress heroku
  • 事业单位网站建设算固定资产吗企业门户网站网站怎么获得
  • 网站欣赏网站欣赏网页设计主题描述
  • 网站后台管理系统 静态页面青铜峡建设局网站
  • 服装时尚网站沈阳人流
  • 免费网站建设开发中国建筑装饰网下载
  • qq空间网站根目录搜索引擎原理
  • 做视频点播网站要多少带宽简单响应式网站设计代码
  • 极简建站开发网站开票名称是什么原因
  • 毕业设计做一个网站怎么做wordpress 文章密码
  • 网站 成功因素商务网站教程
  • 四川大学官方网站规划建设处柳州网站seo网站s
  • 原创设计师品牌网站网站如何制作多少钱