Vue created asynchronous request, error in assignment

I have two child parent components. The list, obtained by the parent component for asynchronous requests in create uses prop to render data to the child component, but when it comes to the child component, the list is undefined; if the list is initialized to an empty array in the data of the parent component, the list in the child component is an empty array; that is, the list assignment is invalid in create.

xhr.png

.png

.png

with webpack deployment, modified files can be displayed normally after hot loading, but not after refreshing.

Mar.16,2021

do not put list into obj, which will cause the vue to fail to listen for list changes. Put list in the root attribute


because the child component renders before the parent component. The general processing is to write a value with no data but structure in data in advance, and then asynchronous request overrides this value


assign it with this.$set (). It should be because the assignment of attributes in the object cannot be monitored


it seems unnecessary to this.$nextTick (), you delete $nextTick () try


problem solved, use watch to listen for data changes before component rendering, the reason should be that dom rendering is finished but the data is not updated, so the data obtained in the component is empty

.
Menu