Vue error TypeError: Cannot read property 'length' of undefined?


vue editors report such an error without jumping while loading it all the time.

Mar.04,2021

that depends on where your code writes a variable .length of undefined.


should be a for loop or something like arr.length is written in the judgment, but arr means undefined, to see if it doesn't get a value. The meaning of


is that there is no definition. If you don't see what your code has written, it may be because you obtained the data asynchronously, and there is a problem with the execution time


if the page rendering is normal, the data (array) has not been requested yet. For example, if an array for loop is nested under an array for loop in the html template, this phenomenon will occur. You can solve

by adding a vmuriff = "data.length! = = 0" to the first loop of the template.
Menu