[Vue warn]: Error in callback for watcher “lists“: “TypeError: Cannot read property ‘length‘ of unde
[Vue warn]: Error in callback for watcher “lists”: “TypeError: Cannot read property ‘length’ of undefined”

原因是 props父传子 的时候, 父组件data中 初始化的值是{},但是子组件接收的时候,初始化是[]
父组件:
[Vue warn]: Error in callback for watcher “lists“: “TypeError: Cannot read property ‘length‘ of unde
子组件:
[Vue warn]: Error in callback for watcher “lists“: “TypeError: Cannot read property ‘length‘ of unde

消除警告的办法是:
父组件
[Vue warn]: Error in callback for watcher “lists“: “TypeError: Cannot read property ‘length‘ of unde
加上这个[]

相关文章: