[Vue warn]: Error in render: "TypeError: Cannot read property 'length' of undefined"

TypeError: Cannot read property 'length' of undefined
[Vue warn]: Error in render: "TypeError: Cannot read property 'length' of undefined"

Cannot read property 'length' of undefined

  1. 某个数组没值导致的问题
  2. 写了this.$emit('getDate', val)提交的方法的同时,又定义了this.$refs['formName'].getDate()方法导致的

数组赋值字段为null

Error in getter for watcher "parsedValue": "TypeError: Cannot read property 'length' of null"

  • 接口返回字段给数组设置默认值时,注意返回字段为null, 而不是空字符串,会报以上错误。
  • 解决方案:给赋值数组定义默认值let arr = [a1||'', a2||'']

推荐阅读更多精彩内容