1、JSON.stringify(data) 这个函数可以将json对象转换成json字符串
2.使用https://www.bejson.com/ 可以将json字符串转换为json对象,查看json的结构。
var result = '';
for (var i = 0; i < data.length; i++) {
var time = new Date(parseInt(data[i].add_time) * 1000).toLocaleString();
var img = ''
for(var j = 0; j < data[i].pic.length; j++){
img += '<li class="weui-uploader__file" style="background-image:url('+data[i].pic[j].tiezipic+');position: relative;"> </li>';
}
// result += '<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg"> <div class="weui-media-box__hd" style="width: 70px;height: 70px;"> <img class="weui-media-box__thumb" src="{$Think.const.IMG_URL}a.jpg" alt=""> </div> <div class="weui-media-box__bd"> <h4 class="weui-media-box__title">十月一国庆房产众筹活动</h4> <p class="weui-media-box__desc"> <div class="" style="color: #f2852a;font-size: 14px;"> SN码:'+data[i].snma+' </div> <div style="color: #7f7f7f;"> 购买时间:'+time+' </div> </p> </div> </a>'
result += '<div class="itemTie"> <!-- 发帖人信息状态 --> <div class="weui-row" style="margin:4% 0;"> <div class="weui-col-10"> <img src="'+data[i].user_img+'" class="userPhoto" /> </div> <div class="weui-col-80"> <h4 class="userName">'+data[i].user_nickname+'</h4> <div class=""> '+time+' </div> </div> </div> <!-- 标题和内容 --> <div class="weui-row"> <a href="" class="tTitle"> '+data[i].tiezi_title+'</a> <div class="tDescription"> '+data[i].tiezi_content+'</div> </div> <!-- 帖子图片 --><a href="" class="weui-row"> <div class="weui-cell__bd"> <div class="weui-uploader"> <div class="weui-uploader__bd"> <ul class="weui-uploader__files" id="uploaderFiles" style="padding: 10px 0;">'+img+'</ul> </div> </div> </div> </a><!-- 评论和点赞 --> <div class="tState cl"> <ul> <li> 666 <i class="icon iconfont"></i> </li> <li> 12 <i class="icon iconfont"></i> </li> </ul> </div> </div>'
}
return result;