2017-09-30 52 views
1

這是VUE網格例如:手柄VUE網格導致

var demo = new Vue({ 
     el: '#demo', 
     data: { 
      searchQuery: '', 
      gridColumns: ['name', 'power'], 
      gridData: [ 
       { name: 'Chuck Norris', power: Infinity }, 
       { name: 'Bruce Lee', power: 9000 }, 
       { name: 'Jackie Chan', power: 7000 }, 
       { name: 'Jet Li', power: 8000 } 
      ] 
     } 
    }); 

這是返回內部數據thwo項

demo.$http.get('http://localhost:8001/people') 
     .then(response => { 
      console.log(response.body); 
     }, response => { 
      console.log('something went wrong'); 
     }); 

這樣一個要求:

{ 
data: [ 
    { 
    name: "Simone", 
    power: "Infinity" 
    }, 
    { 
    name: "Chuck", 
    power: "Simonity" 
    } 
] 
} 

如何在gridData中放置響應?

回答

1

嘗試使用push()方法爲您gridData陣列:

demo.$http.get('http://localhost:8001/people') 
    .then(response => { 
     for (let i in response.data) 
      demo.gridData.push(response.data[i]); 
    }, response => { 
     console.log('something went wrong'); 
    });