The page loads the content, but the console reports an error, showing that the attribute name cannot be found

The error is as follows:

 

My page can clearly display the data of this attribute, but the console shows that the name attribute cannot be found. This is because the function that encapsulates the request interface is used, and the obtained data is saved and rendered to the dom element, but before the data is rendered, the dom The element will be rendered once to render the obtained data. Then it will cause the data obtained by rendering to be undefined, without this attribute/object.

It is equivalent to the requested data has not been saved, you go to access the data, you must not be able to find it, and the page will be rendered after the data is saved later, so the error is reported

The problem code is as follows:

 

At this time, because the data I want is an array, the array is empty at the beginning, and there is data later, so I only need to add a judgment in front to judge whether the array has a length.

If the data you want to query is an object, judge whether the object has that attribute name, such as v-if="object.name "

Guess you like

Origin blog.csdn.net/qq_59020839/article/details/131678114