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

动态网站建设案例教程电子书下载推广业务

动态网站建设案例教程电子书下载,推广业务,wang域名建的网站,编程代码怎么学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.wooajung.com/news/28307.html

相关文章:

  • php 调用其他网站线上销售的方法和技巧
  • 做网站需要买网址吗关键词搜索优化外包
  • 番禺做网站哪家专业宁波网站优化公司价格
  • 自己建设的网站打开慢最新新闻
  • 宜昌建设网站电商培训机构排名
  • 专业商城网站建设制作网站的步骤
  • 宣威网站谷歌google地图
  • 做网站需要哪些人员漯河seo推广
  • 网站后台模板免费下载西安网站搭建公司
  • 做网站卖假名牌违法吗常见的网络营销推广方式有哪些
  • 医院网站源码 aspaso优化技巧
  • 天津网站制作公司电话网站建设公司服务
  • 深圳有实力的网站建设服务商百度站长提交网址
  • wordpress 首页加载延迟搜索引擎优化网站
  • 新浪短网址链接生成器2022最好的百度seo
  • 外贸网站建设方法南宁网
  • 获取网站访客qq号北京网站优化快速排名
  • 网站cmd做路由分析成都网站优化
  • 英文网站建设飞猪关键词排名优化
  • 南京网站建设公司哪家好百度一下你就知道搜索
  • 汽车网站策划sem营销推广
  • 北京大兴企业网站建设哪家好中国十大软件外包公司排名
  • 威海做网站哪家好宁波网站建设团队
  • 郑州做旅游网站怎么申请网站空间
  • 广东深圳福田区无锡网站seo顾问
  • 安阳网站制作哪家好seo推广公司哪家好
  • 深圳做营销网站公司上海网站搜索引擎优化
  • 做好的网站怎么发布外贸展示型网站建设公司
  • 做网站开发用sublime好吗公众号运营收费价格表
  • seo搜索引擎优化兴盛优选seo工具包括