当前位置:网站首页>原生DOM与虚拟DOM
原生DOM与虚拟DOM
2022-06-25 23:13:00 【南初️】
- 首先,我们需要搞清楚两个概念,什么是原生dom,什么是虚拟dom?
- 传统的开发模式
- 原生JS或JS操作DOM时,浏览器会从构建DOM树开始从头到尾执行一遍流程。
- 在一次操作中,我需要更新10个DOM节点,浏览器收到第一个DOM请求后并不知道还有9次更新操作,因此会马上执行流程,最终执行10次。
- 虚拟DOM
- Web界面由DOM树(树的意思是数据结构)来构建,当其中一部分发生变化时,其实就是对应某个DOM节点发生了变化。
- 一次操作中有10次更新DOM的动作,虚拟DOM不会立即操作DOM,而是将这10次更新的diff内容保存到本地一个JS对象中,最终将这个JS对象一次性attch到DOM树上,再进行后续操作,避免大量无谓的计算量。
- 虚拟DOM的好处
- 用JS对象模拟DOM节点的好处是,页面的更新可以先全部反映在JS对象(虚拟DOM)上,操作内存中的JS对象的速度显然要更快,等更新完成后,再将最终的JS对象映射成真实的DOM,交由浏览器去绘制。
边栏推荐
猜你喜欢

Px4 system terminal for pixhawk

The maze of God's perspective in robot vision

Why is it best to use equals for integer comparisons

CXF

Motor monitoring system based on MCGS and stm32

多接口调用,使用Promise.all、Promise.race和Promise.any

FreeRTOS+STM32L+ESP8266+MQTT协议传输温湿度数据到腾讯云物联网平台

Nacos registry

Return value is object type method call equals()

Modelsim simulation FFT core cannot be simulated solution (qsys)
随机推荐
mtb13_ Perform extract_ blend_ Super{candidate (primaryalternate) \u unique (nullable filtering \foreign\index\granulati
Implementation notes of least square fitting conic in stm32
213. house raiding II
Redis strings command
Mining pit record of modified field information in Dameng database
Web學習之TypeScript
JS逆向案例:破解登录密码
Music spectrum display toy -- implementation and application of FFT in stm32
Msp430f5529lp official board (red) can not debug the problem
Spark log analysis
Electronic training.
C#使用MySql进行操作
SVN
随便画画的
How product managers control the progress of product development
QT excellent open source project 9: qtox
Flex & bison start
简单 deepclone
Unknown device ID does not appear on the STM32 st-link utility connection! Causes and Solutions
The cache page stores the initial parameters after the route jump under the react + router framework