vue循环渲染接口数据
app = new Vue({
el: '#app',
data:{
sites:[]
},
mounted(){
axios.get("url").then(response=>(this.sites=response.data.data))
},
});
<div id="app">
<table>
<thead>
<tr>
<th>id</th>
<th>姓名</th>
<th>电话</th>
</tr>
</thead>
<tbody>
<tr v-for="site in sites">
<td>{{site.name}}</td>
<td>{{site.phone}}</td>
</tr>
</tbody>
</table>
</div>
response.data.data 就是接口json里的data数组
response.data 就是整个后端返回的json对象