The difference between dom in vue and react
The difference between vue and dom in react: 1. Vue will track the dependencies of each component and does not need to re-render the entire component tree; 2. For React, whenever the state of the application is changed, All components will be re-rendered.
The operating environment of this article: windows7 system, react17.0.1&&vue2.0 version, Dell G3 computer.
The concept of virtual DOM was born with the birth of react. It was proposed by Facebook. Its excellent performance was quickly recognized by the majority of developers; after react, vue2.0 also introduced the concept of virtual DOM at its core. .
What is virtual DOM?
Virtual dom is relative to the real dom rendered by the browser. Before the emergence of react, vue and other technologies, we could only change the content displayed on the page by traversing the query dom tree to find what needs to be modified. The dom then modifies the style behavior or structure to achieve the purpose of updating the ui.
This method consumes quite a lot of computing resources, because almost every time you query the dom, you need to traverse the entire dom tree. If you create a virtual dom object (js object) corresponding to the dom tree, in the form of object nesting To represent the dom tree, then every change of the dom becomes a change of the properties of the js object. In this way, the performance overhead of searching for the property changes of the js object is smaller than that of querying the dom tree.
The difference between virtual DOM in vue and react
The virtual DOM (virtual DOM) in vue and react is different.
Vue will track the dependencies of each component and does not need to re-render the entire component tree.
For React, every time the application state is changed, all components will be re-rendered, so the shouldComponentUpdate life cycle function method is needed in react for control.
Recommended: "js Basic Tutorial"
The above is the detailed content of The difference between dom in vue and react. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Vue.js is suitable for small and medium-sized projects and fast iterations, while React is suitable for large and complex applications. 1) Vue.js is easy to use and is suitable for situations where the team is insufficient or the project scale is small. 2) React has a richer ecosystem and is suitable for projects with high performance and complex functional needs.

You can add a function to the Vue button by binding the button in the HTML template to a method. Define the method and write function logic in the Vue instance.

There are three ways to refer to JS files in Vue.js: directly specify the path using the <script> tag;; dynamic import using the mounted() lifecycle hook; and importing through the Vuex state management library.

The watch option in Vue.js allows developers to listen for changes in specific data. When the data changes, watch triggers a callback function to perform update views or other tasks. Its configuration options include immediate, which specifies whether to execute a callback immediately, and deep, which specifies whether to recursively listen to changes to objects or arrays.

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

React combines JSX and HTML to improve user experience. 1) JSX embeds HTML to make development more intuitive. 2) The virtual DOM mechanism optimizes performance and reduces DOM operations. 3) Component-based management UI to improve maintainability. 4) State management and event processing enhance interactivity.

Vue.js has four methods to return to the previous page: $router.go(-1)$router.back() uses <router-link to="/" component window.history.back(), and the method selection depends on the scene.

You can query the Vue version by using Vue Devtools to view the Vue tab in the browser's console. Use npm to run the "npm list -g vue" command. Find the Vue item in the "dependencies" object of the package.json file. For Vue CLI projects, run the "vue --version" command. Check the version information in the <script> tag in the HTML file that refers to the Vue file.
