js遍历ajax得到的数据,Vue.js用v-for怎么获取ajax的数据
{{list.message}}var arr=new Array();var message=$.ajax({url: '/laravel/public/DanmakuR/DanmakuR_main_player_video_message_center/1',type: 'get',dataType: 'json',}).done(function() {for (var i = 0; i &
{{list.message}}
var arr=new Array();
var message=$.ajax({
url: '/laravel/public/DanmakuR/DanmakuR_main_player_video_message_center/1',
type: 'get',
dataType: 'json',
})
.done(function() {
for (var i = 0; i < message.responseJSON.length; i++) {
arr[i]={message:message.responseJSON[i].message,url:message.responseJSON[i].url};
}
})
.fail(function() {
//console.log("error");
})
.always(function() {
//console.log("complete");
});
console.log(arr);
var app=new Vue({
el:"#app",
data:{
msgList:arr,
},
});
ajax返回的数据
[{"uuid":"22056b8f-aa6c-11e7-94fa-005056c00001","message":"\u6d4b\u8bd5\u8fde\u63a5","url":"http:\/\/192.168.1.1"},{"uuid":"75f1db62-aa6c-11e7-94fa-005056c00001","message":"test2","url":"http:\/\/192.168.1.2"}]
更多推荐
所有评论(0)