它传来的值是这样的
{"resultcode":"200","reason":"SUCCESSED!","result":[{"1":{"variety":"Au100g","latestpri":"268.50","openpri":"269.02","maxpri":"269.62","minpri":"268.50","limit":"-0.37%","yespri":"269.50","totalvol":"306.00","time":"2018-07-12 15:04:49"},"2":{"variety":"Au(T+N1)","latestpri":"--","openpri":"--","maxpri":"--","minpri":"--","limit":"--","yespri":"278.25","totalvol":"--","time":"2018-07-11 20:00:00"},"3":{"variety":"Au(T+D)","latestpri":"268.01","openpri":"269.13","maxpri":"269.38","minpri":"267.96","limit":"-0.40%","yespri":"269.08","totalvol":"40132.00","time":"2018-07-12 15:07:36"},"4":{"variety":"Au99.99","latestpri":"268.10","openpri":"269.40","maxpri":"269.40","minpri":"268.10","limit":"-0.33%","yespri":"269.00","totalvol":"92509.00","time":"2018-07-12 15:07:23"},"5":{"variety":"Au99.95","latestpri":"268.10","openpri":"268.65","maxpri":"268.65","minpri":"268.10","limit":"-0.33%","yespri":"269.00","totalvol":"360.00","time":"2018-07-12 15:04:29"},"6":{"variety":"Au50g","latestpri":"--","openpri":"--","maxpri":"--","minpri":"--","limit":"--","yespri":"255.00","totalvol":"--","time":"2018-07-11 20:00:00"},"7":{"variety":"Ag99.99","latestpri":"--","openpri":"--","maxpri":"--","minpri":"--","limit":"--","yespri":"3700.00","totalvol":"--","time":"2018-07-11 20:00:00"},"8":{"variety":"Ag(T+D)","latestpri":"3649.00","openpri":"3655.00","maxpri":"3663.00","minpri":"3642.00","limit":"-0.19%","yespri":"3656.00","totalvol":"2616764.00","time":"2018-07-12 15:07:37"},"9":{"variety":"Au(T+N2)","latestpri":"271.85","openpri":"273.70","maxpri":"273.85","minpri":"271.85","limit":"-0.46%","yespri":"273.10","totalvol":"8912.00","time":"2018-07-12 14:55:09"},"10":{"variety":"Pt99.95","latestpri":"194.00","openpri":"193.60","maxpri":"194.00","minpri":"193.60","limit":"-0.59%","yespri":"195.16","totalvol":"30.00","time":"2018-07-12 15:06:17"}}],"error_code":0
}
gold.js
Page({onLoad: function() {var that = this;wx.request({url: 'http://web.juhe.cn:8080/finance/gold/shgold?key=自己去申请',header: {'content-type': 'application/json'},success: function(res) {console.log(res.data)that.setData({goldData: res.data.result[0],})}})}
})
<!--pages/gold/gold.wxml-->
< text class= "title" >黄金数据 </ text >< block wx:for= "{{goldData}}" wx:key= "this" >
< view class= "gold" >
< view class= "variety" >|品种:{{item.variety}} </ view >
< view class= "latestpri" >|最新价:{{item.latestpri}} </ view >
< view class= "openpri" >|开盘价:{{item.openpri}} </ view >
< view class= "maxpri" >|最高价:{{item.maxpri}} </ view >
< view class= "minpri" >|最低价:{{item.minpri}} </ view >
< view class= "limit" >|涨跌幅:{{item.limit}} </ view >
< view class= "yespri" >|昨收价:{{item.yespri}} </ view >
< view class= "totalvol" >|总成交量:{{item.totalvol}} </ view >
< view class= "time" >|更新时间:{{item.time}} </ view >
< view class= 'dLine' >-------------------------------- </ view >
</ view ></ block >