Why do dom changes caused by data updates in vue use asynchronous updates? doesn"t Synchronize code operate the dom browser and render together in the last stage of eventloop?
this is the decomposition of the problem
Why do dom changes caused by data updates in vue use asynchronous updates? doesn"t Synchronize code operate the dom browser and render together in the last stage of eventloop?
this is the decomposition of the problem
you set the height to a dom, and then get the height, what the browser will do
vue uses asynchronous updates, which is essentially an update optimization for virtual dom.
the essence of virtual dom is to use Javascript objects to simulate dom trees. If you synchronize multiple updates, and if each update of data data has a great impact on this object, it is bound to bring unnecessary redundant computation. As long as the last update is not good ~
export default {
data () {
return {
test: 0
};
},
mounted () {
for(let i = 0; i < 1000; iPP) {
this.testPP;
}
}
}
now there is a situation where the value of test is executed 1000 times by PP loop when mounted. Each time PP, setter- > Dep- > Watcher- > update- > patch is triggered according to the response. If the view is not updated asynchronously at this time, then every time PP will directly manipulate DOM to update the view, which is very performance-consuming. So Vue.js implements a queue queue, which uniformly executes the run of the Watcher in the queue at the next tick. At the same time, Watcher with the same id will not be added to the queue repeatedly, so the run of Watcher will not be executed 1000 times. In the end, updating the view will only directly change the 0 of the DOM corresponding to test to 1000. The action to ensure that the update view operation DOM is called on the next tick after the current stack has finished execution greatly optimizes performance.
original address: https://github.com/answershut...
Please recommend the library reported by error monitoring at the front end, or post relevant codes the discovery written by myself is not comprehensive, unable to listen for resource errors, but can only listen for run-time errors. I don t know if th...
question: vue-cli modifies the file under MAC. It doesn t compile automatically, and it doesn t report an error. What s going on here? Action: the webstorm I used turned off the safewrite and it didn t work. Changing the editor won t work. I can t...
does anyone use Huanxin for webim development? an error is reported at the file introduction stage. I hope there can be an open source example to refer to . It is best to use vue to develop ....
for example, I used npm install amazeui to download a dependent amazeui . there are js and css, in this amazeui. At this time, I want to reference these js in vue to get css,. What should I do? Do not use the reference method of the folder path, plea...
let ar = [1,2,3] 1[2[3]]...
introduce mui, into the vue project and then use the mui message box in js, but always report an error index.html main.js request.js ask for help ~ how to introduce guessing correctly, because it seems that this mui cannot be installed with webpac...
when using the confirm confirmation box of vux, the pop-up box comes out, but the program has not yet been confirmed, and the program has continued to run. May I ask how to solve this problem, such as. Then, you have to run well above before you continu...
for example, I have a set of data [ { time : 2018-03-01 , data : 1, }, { time : 2018-02-02 , data : 2, }, { time : 2018-01-01 , data : 3, }, { time : 2017-12-01 , data : ...
problem description this is what I wrote on index.html: <html> <body> <div id="app"> <sidenav>...< sidenav> <navbar>...< navbar> < div> <script src="main.js" > <...
assume that the current subcomponent is just a button, and the data data of the subcomponent will be changed when the button is clicked. Why does this trigger only the updated of the child component and not the updated of the parent component? is th...
the following error occurred when creating a project using vue-cli: Command: vue create vue-hello error report: npm ERR! Unexpected end of JSON input while parsing near ...ant":"^2.2.2","semver npm ERR! A complete log of t...
this error is often reported at compile time. I have no idea. [44024:0x103000600] 603346 ms: Scavenge 1321.7 (1352.4)-> 1321.3 (1352.9) MB, 2.50.0 ms (average mu = 0.240, current mu = 0.189) allocation failure [44024:0x103000600] 603373 ms: Scaveng...
<div class="panel" @mousemove="mv1">debounce=========={{msg1}}< div> is a piece of code written in the vue component mv1:function(e){ var timer ; clearTimeout(timer); timer = setTimeout(this.msg1PP,5000)...
Vue detects changes in data through Object.defineProperty, so it s understandable that you can t listen for array additions, because this detection binding operation has already been done for all properties in the constructor. but the official text: ...
I found a solution, which is to change the value of limit in webpack.base.conf.js from 10000 to 1000000, but it doesn t feel like an appropriate method. What should I do? ...
<template> <div class="login-wrap"> <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="80px" class="demo-ruleForm login-f...
the examples I search on the Internet are called in the following ways. I want to know how to use export default in the webpack template to call it? Vue.directive( focus , { DOM inserted: function (el) { el.focus() } }) ...
The page can be displayed normally, but the console reports an error error message [Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting bloc...
chrome browser can upload pictures normally. if you use uploaded pictures in ie10, you will report an error Error: parameter is invalid. ...
as there are more and more routes, more and more components are introduced into router.js, and each particular page corresponds to a different component. is this a reasonable way to write? It feels weird ...