How to suppress “Undefined” errors before fetching data in Vue

前端 未结 3 697
时光说笑
时光说笑 2021-01-24 03:54

I have a simple page where I display some data that are fetched from the server.

Template:

Order\'s customer name: {{ order.customer.name }}<

3条回答
  •  一向
    一向 (楼主)
    2021-01-24 04:23

    You can use ternary operator to check

    Order's customer name: {{ order.customer?order.customer.name:'' }}

提交回复
热议问题