vue solution code needs to be executed after dom rendering
Used when the code needs to be delayed until the dom is executed after the new rendering
- The component's .$nextTick (callback function) method will postpone the callback until the next DOM update cycle is executed. The common understanding is: after the component DOM is updated, the callback function is executed, so as to ensure that the callback function can operate the latest DOM element.
- Executing the following code will cause an error, because when executing the above code, the page will not be rendered immediately after the value changes (life cycle function beforUpdata), so the value of ref cannot be obtained.
- Why can't I write it to the updatedata (because I will perform a time to get the focus after clicking. When the input box loses the focus, I need to get the focus again. At this time, the input box is already hidden) This.$() cannot be used here;
vue (data changes, DOM does not render)
1. Inside the component
The reference address in the attribute value address space changes, and the DOM cannot render.
Examples of problems:
= [[],[],[],[]]
In items, modify the value in any array, the DOM will not be updated.
Solution:
= [...]
By deconstructing the assignment, reassign the items.
2. Pass values between components
The parent component passes data to change, and the child component is not updated.
The value passed by the parent component in mounted is judged and other related processing, and the effect is achieved by changing the state defined by the child component itself.
At this time, the parent component value is updated and the child component does not re-render because the parent component value changes the child component and the child component will not go through the mounted life cycle.
Solution:
Use watch to listen for the value passed by the parent component, and perform corresponding operations when the value changes.
Recommended use:
The value passed by the parent component is directly used in the child component. If type conversion or simple judgment is required, and the use is directly judged through the three-point operator, the listening step of passing the value to the parent component is omitted.
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.