Vue warning when accessing nested object

后端 未结 2 1558
清酒与你
清酒与你 2021-01-17 05:36

I am not sure why I get a Vue warning when accessing nested object.

{{ user.area.name }}

[Vue warn]: Error in render: \"Type

2条回答
  •  借酒劲吻你
    2021-01-17 06:04

    Your user doesn't contain an area, so when you try to read that, it's undefined. You're not allowed to use the . operator on things that are undefined, so when you do .name on that, you get the error that you got.

提交回复
热议问题