[vue] What is virtual DOM?

[vue] What is virtual DOM?

虚拟 dom 是相对于浏览器所渲染出来的真实 dom 的,在react,vue等技术出现之前,我们要改变页面展示的内容只能通过遍历查询 dom 树的方式找到需要修改的 dom 然后修改样式行为或者结构,来达到更新 ui 的目的。

这种方式相当消耗计算资源,因为每次查询 dom 几乎都需要遍历整颗 dom 树,如果建立一个与 dom 树对应的虚拟 dom 对象( js 对象),以对象嵌套的方式来表示 dom 树,那么每次 dom 的更改就变成了 js 对象的属性的更改,这样一来就能查找 js 对象的属性变化要比查询 dom 树的性能开销小。

Personal profile

I am a song, welcome to share front-end and back-end knowledge with you. It is easy to give up,
but it must be cool to persist. Welcome everyone to discuss

Main directory

Clear the front-end interview questions with song

Guess you like

Origin blog.csdn.net/weixin_43392489/article/details/114236276