為什么從data-xxx獲取數(shù)據(jù)顯示Undefined

今天寫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

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容