一切都好了,急需一份json代码,格式弄不对,谢谢啦
谢谢大家了,谢谢
谢谢大家了,谢谢
2018-08-16
java代码附上
@Controller
@RequestMapping(value = "/wxAuth")
public class WxAuthController {
@RequestMapping(value = "/proData")
@ResponseBody
public JSONArray proData() {
String json = "[{\"log\":\"1\",\"title\":\"test\",\"desc\":\"descdescdesc\"},{\"log\":\"2\",\"title\":\"test\",\"desc\":\"descdescdesc\"},{\"log\":\"3\",\"title\":\"test\",\"desc\":\"descdescdesc\"}]";
JSONArray jsonArray = JSONArray.fromObject(json);
return jsonArray;
}
}
/* 文件名: data.json */
{
"proList": [
{"img":"/images/1.jpg","title":"精英贷","desc":"22周岁以上即可 最快3小时下款"},
{"img":"/images/1.jpg","title":"月供贷","desc":"22周岁以上即可 最快3小时下款"}
]
}
注意:我这里JSON文件的数据,在index.js页面上的 self.setData({ proList: res.data }); 代码,要改成:
self.setData({ proList: res.data.proList });
即在末尾加上数组的名称"proList"(这个是我在json文件里自己定义的,也可以写别的),当然img图片路径的要写本地有的哦!
{
"data":[
{
"img": "/images/pro_01.jpg",
"title": "test",
"desc": "abfgnsfgmghhjhk对方不知道发给你dsad"
},
{
"img": "/images/pro_02.jpg",
"title": "test",
"desc": "a不VB你是否给你他还没呢发VB才把sdsad"
},
{
"img": "/images/pro_03.jpg",
"title": "test",
"desc": "asdsvdfvbadfbhsabharnbfsfbhsfbad"
},
{
"img": "/images/pro_01.jpg",
"title": "test",
"desc": "asd地方广播电视台功能和覆盖面不出现sad"
}
]
}
举报