{"status":true,"data":[{"ref_id":"22","agent_id":"68","p_id":"84","description":"i am interested"},{"ref_id":"24","agent_id":"68","p_id":"84","description":"For more information about Bootstrap and Bootstrap Glyphicons, visit our Bootstrap Tutorial.For more information about Bootstrap and Bootstrap Glyphicons, visit our Bootstrap Tutorial"}
如何使用vue js显示上述DATA值?
目前我使用,但没有工作..
<table>
<tbody>
<tr v-for="post in posts">
<td>{{ post.p_id }}</td>
</tr>
</tbody>
</table>
答案 0 :(得分:0)
您的给定数据不完整。如果给定数据为posts
响应,则使用posts.data
代替posts
var vm = new Vue({
el: '#vue-instance',
data: {
posts:{"status":true,"data":[{"ref_id":"22","agent_id":"68","p_id":"84","description":"i am interested"},{"ref_id":"24","agent_id":"68","p_id":"84","description":"For more information about Bootstrap and Bootstrap Glyphicons, visit our Bootstrap Tutorial.For more information about Bootstrap and Bootstrap Glyphicons, visit our Bootstrap Tutorial"}]
},
}
});
&#13;
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.js"></script>
<div id="vue-instance">
<table >
<tbody>
<tr v-for="post in posts.data">
<th >Ref Id</th>
<th >Agent Id</th>
<th >PID</th>
</tr>
<tr v-for="post in posts.data">
<td>{{ post.ref_id }}</td>
<td>{{ post.agent_id }}</td>
<td>{{ post.p_id }}</td>
</tr>
</tbody>
</table>
</div>
&#13;