B
B
beduin012018-07-29 11:32:54
Vue.js
beduin01, 2018-07-29 11:32:54

Why can't I reach the property?

<div>{{my_data['2018-07-11']}} </div>
Output:
{ "may": 4, "june": 8, "april": 5 }
This code:
<div>{{my_data['2018-07-11']['may']}} </div>
Output 4. But on the console I get an error:

Error in render: "TypeError: Cannot read property 'may' of undefined"

The application code itself:
var app = new Vue({
  el: '#app',
  data: {
    my_data: {},
    mess: 'hello world'
  },

     created: async function(){
    	url = 'http://dlang.ru/test'
    const response = await fetch(url);
    this.my_data = await response.json();

    } 	
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2018-07-29
@beduin01

Because at the time of rendering the template, the data has not yet arrived and the object with the data is empty.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question