wxml
<view class="successlist"> <span>来访理由</span> <span wx:if="{{list.visitCause==0}}"> 面试</span> <span wx:elif="{{list.visitCause==1}}"> 开会</span> <span wx:elif="{{list.visitCause==2}}"> 拜访顾客</span> <span wx:elif="{{list.visitCause==3}}"> 项目实施</span> <view wx:else> 其他 </view> </view>
js
Page({ data: { list: [], }, onLoad: function(options) { wx.request({ url: "http://ixxxe.com/test.json", data: { }, method: 'GET', header: { 'content-type': 'application/json' }, success: res => { this.setData({ //第一个data为固定用法,第二个data是json中的data list: res.data.data }) } }) }, })
json
{ "msg": "查询成功", "code": 1, "data": { "visitCause": 0 } }
显示:
json
{ "msg": "查询成功", "code": 1, "data": { "visitCause": 1 } }
显示:
json
{ "msg": "查询成功", "code": 1, "data": { "visitCause": 2 } }
显示:
json
{ "msg": "查询成功", "code": 1, "data": { "visitCause": 3 } }
json
{ "msg": "查询成功", "code": 1, "data": { "visitCause": 4 } }
本文摘自 :https://blog.51cto.com/u