vue principle

Vue is a progressive framework that adopts a bottom-up incremental development model. Vue is different from Angela. Vue is lightweight, Angela is a family bucket, Angela is very large, but the functions are very complete, and it is a complete set , vue is just a vue.js library. If you want routing function, you need to install vue-router library. This is the difference between the two. React and vue are almost lightweight, but the syntax is different
. One of the cores of vue The two-way binding of data is implemented using Object.defineProperty. Its function is to define a get function and a set function for the specified property. The meaning of the function is the same as the name. When the user triggers a data change, vue will monitor the function. It is added to the set function, which will trigger a listener function when the data changes. In the listener function, the bound dom elements and other things such as watch and computed properties are updated, thus realizing a two-way binding. , but sometimes his monitoring is not very good, because the api used to achieve two-way binding has compatibility problems, so only ie9+ is supported
in the virtual dom that is one of the cores. This is the solution adopted by vue and react. Almost, but react runs much faster than vue, because there are too many properties that the native dom node does not use (created by document.createElement), it is too expensive to traverse this thing, so there is a virtual dom, virtual The dom is simulated by javascript objects, which only contain the properties that are used, so it is much faster to traverse and compare, because vue will update the page when the data changes, but vue does not know what has changed. So we can only re-render all the things associated with the changed attributes. This rendering is not to delete the original things and create a new one, but to assemble the new data into the virtual DOM and the original rendered virtual DOM. A comparison, rendering the difference on the page, this comparison process is called the diff algorithm

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324737230&siteId=291194637