wxml
<view class="successlist"> <span>來(lái)訪理由</span> <span wx:if="{{list.visitCause==0}}"> 面試</span> <span wx:elif="{{list.visitCause==1}}"> 開會(huì)</span> <span wx:elif="{{list.visitCause==2}}"> 拜訪顧客</span> <span wx:elif="{{list.visitCause==3}}"> 項(xiàng)目實(shí)施</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({ //第一個(gè)data為固定用法,第二個(gè)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