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

北京做网站好公司百度推广开户

北京做网站好公司,百度推广开户,广告策划书范本,网站维护常识Virtual DOM 这个概念相信大部分人都不会陌生,它产生的前提是浏览器中的 DOM 是很“昂贵"的,为了更直观的感受,我们可以简单的把一个简单的 div 元素的属性都打印出来,如图所示: 可以看到,真正的 DOM …

Virtual DOM 这个概念相信大部分人都不会陌生,它产生的前提是浏览器中的 DOM 是很“昂贵"的,为了更直观的感受,我们可以简单的把一个简单的 div 元素的属性都打印出来,如图所示:

可以看到,真正的 DOM 元素是非常庞大的,因为浏览器的标准就把 DOM 设计的非常复杂。当我们频繁的去做 DOM 更新,会产生一定的性能问题。

而 Virtual DOM 就是用一个原生的 JS 对象去描述一个 DOM 节点,所以它比创建一个 DOM 的代价要小很多。在 Vue.js 中,Virtual DOM 是用 VNode 这么一个 Class 去描述,它是定义在 src/core/vdom/vnode.js 中的。

export default class VNode {tag: string | void;data: VNodeData | void;children: ?Array<VNode>;text: string | void;elm: Node | void;ns: string | void;context: Component | void; // rendered in this component's scopekey: string | number | void;componentOptions: VNodeComponentOptions | void;componentInstance: Component | void; // component instanceparent: VNode | void; // component placeholder node// strictly internalraw: boolean; // contains raw HTML? (server only)isStatic: boolean; // hoisted static nodeisRootInsert: boolean; // necessary for enter transition checkisComment: boolean; // empty comment placeholder?isCloned: boolean; // is a cloned node?isOnce: boolean; // is a v-once node?asyncFactory: Function | void; // async component factory functionasyncMeta: Object | void;isAsyncPlaceholder: boolean;ssrContext: Object | void;fnContext: Component | void; // real context vm for functional nodesfnOptions: ?ComponentOptions; // for SSR cachingfnScopeId: ?string; // functional scope id supportconstructor(tag?: string,data?: VNodeData,children?: ?Array<VNode>,text?: string,elm?: Node,context?: Component,componentOptions?: VNodeComponentOptions,asyncFactory?: Function) {this.tag = tagthis.data = datathis.children = childrenthis.text = textthis.elm = elmthis.ns = undefinedthis.context = contextthis.fnContext = undefinedthis.fnOptions = undefinedthis.fnScopeId = undefinedthis.key = data && data.keythis.componentOptions = componentOptionsthis.componentInstance = undefinedthis.parent = undefinedthis.raw = falsethis.isStatic = falsethis.isRootInsert = truethis.isComment = falsethis.isCloned = falsethis.isOnce = falsethis.asyncFactory = asyncFactorythis.asyncMeta = undefinedthis.isAsyncPlaceholder = false}// DEPRECATED: alias for componentInstance for backwards compat.// istanbul ignore nextget child(): Component | void {return this.componentInstance}
}

可以看到 Vue.js 中的 Virtual DOM 的定义还是略微复杂一些的,因为它这里包含了很多 Vue.js 的特性。这里千万不要被这些茫茫多的属性吓到,实际上 Vue.js 中 Virtual DOM 是借鉴了一个开源库 snabbdom 的实现,然后加入了一些 Vue.js 特色的东西。建议大家如果想深入了解 Vue.js 的 Virtual DOM 前不妨先阅读这个库的源码,因为它更加简单和纯粹。

总结

其实 VNode 是对真实 DOM 的一种抽象描述,它的核心定义无非就几个关键属性,标签名、数据、子节点、键值等,其它属性都是用来扩展 VNode 的灵活性以及实现一些特殊 feature 的。由于 VNode 只是用来映射到真实 DOM 的渲染,不需要包含操作 DOM 的方法,因此它是非常轻量和简单的。

Virtual DOM 除了它的数据结构的定义,映射到真实的 DOM 实际上要经历 VNode 的 create、diff、patch 等过程。那么在 Vue.js 中,VNode 的 create 是通过之前提到的 createElement 方法创建的,我们接下来分析这部分的实现。

http://www.dt0577.cn/news/46915.html

相关文章:

  • 个人制作的网站网站开发建站
  • 网站SEO优化实训福州seo网站管理
  • 知名网站欣赏2023年4月疫情恢复
  • 杭州萧山网站建设公司公司网站推广方案
  • 做视频网站设备需求2021近期时事新闻热点事件
  • web制作企业门户网站网站建设服务商
  • 企业所得税会计分录怎么做镇江百度关键词优化
  • 做游戏模板下载网站有哪些百度竞价排名正确解释
  • 靠比较好的软件网站经典seo伪原创
  • 网站设计的公司怎么样优化设计英语
  • 使用vue.js做企业网站广州网站营销推广
  • 手机访问pc网站跳转朝阳区seo搜索引擎优化怎么样
  • 茂名网站优化今天的病毒感染情况
  • 做网站编辑心得seo排名点击软件
  • 广州网站建设年底促销有哪些免费网站可以发布广告
  • 网站收录怎么设置seo引擎优化怎么做
  • 杭州企业建站模板seo基础教程
  • 盗用别人网站图做网站舆情视频
  • 深圳专业o2o网站设计公司四川疫情最新消息
  • 做网站编辑是不是也要做推广日照seo公司
  • 网站建设策划书参考案例现在感染症状有哪些
  • 找柳市做网站扬州网站推广公司
  • 网站模块有哪些百度搜索seo
  • 怎样利用云盘做电影网站网络推广竞价外包
  • 专业做微视频的网站网络营销服务商
  • 校园网站建设重要性爱站网官网查询域名
  • 部门网站建设工作总结口碑营销渠道
  • 别人帮做的网站怎么修改病句软文推广案例
  • 哈尔滨模板建站推荐24小时自助下单平台网站便宜
  • dz论坛如何做网站地图seo搜索排名影响因素主要有