今天寫demo的時(shí)候發(fā)現(xiàn),明明從后臺(tái)獲取到了數(shù)據(jù),但是取出createDate時(shí)間的時(shí)候,在調(diào)試臺(tái)上打印顯示為Undefined。
<li wx:for="{{messageList}}" data-item="item" bindtap="messageDetail" data-messageId="{{item.id}}"
data-createDate="{{item.createDate}}" data-title="{{item.title}}" data-content="{{item.content}}">
<view class="m-title">
<p>{{item.title}}</p>
</view>
<view class="m-content">
<p>內(nèi)容:{{item.content}}</p>
</view>
<view class="m-down">
<p class="m-sendUser">發(fā)送人:{{item.sendBy}}</p>
<p class="m-tongzhi" wx:if="{{item.type==a}}">全員通知</p>
<p class="m-tongzhi" wx:elif="{{item.type==b}}">部門通知</p>
<p class="m-tongzhi" wx:elif="{{item.type==c}}">角色通知</p>
<p class="m-tongzhi" wx:elif="{{item.type==d}}">特定人員通知</p>
<p class="m-tongzhi" wx:else>租戶管理員通知</p>
<p class="m-jinzi" wx:if="{{item.urgentFlag==1}}" style="color:red;">緊急</p>
<p class="m-jinzi" wx:else>非緊急</p>
</view>
</li>
后來(lái)查閱資料發(fā)現(xiàn),data-xxx里面的xxx最好不要有大寫字母,小程序會(huì)自動(dòng)將其轉(zhuǎn)換成小寫,以免自己在template引用是發(fā)生xxx undefined的錯(cuò)誤
參考鏈接:
https://blog.csdn.net/weixin_43915012/article/details/105751437