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

前端 未结 3 695
时光说笑
时光说笑 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:35

    new Vue({
      el: '#app',
      data: {
        data: {name: 'daniel'},
        data2: {}
      }
    })
    
    
    

    You need to render it conditionally. Since data from the backend is not accessible from the very beginning, you should add a condition to display element only when the data is ready. See example.

    Order's customer name:

提交回复
热议问题