uni-app中data-不能傳對象

微信小程序項目轉(zhuǎn)H5頁面遇到一個data-不能傳對象問題
問題代碼

<view :class='[curIndex == index?"active":""]' 
  v-for="(item,index) in infoData" 
  :key="index" 
  :data-index="index"
  :data-item="item"
  @tap='curTime'>{{item.TITLE}}</view>
curTime(e) {
  this.curItem = e.currentTarget.dataset.item;//這里item是一個[Object Object]字符
  this.curIndex = e.currentTarget.dataset.index;
 },

uni-app的JS寫法是Vue的方式可以@tap='curTime(index,item)'的方式傳參,但我想保留:data-index="index"的傳參方式,所以試出了下面的方式。$event可以保留方法默認(rèn)對象

<view :class='[curIndex == index?"active":""]' 
  v-for="(item,index) in infoData" 
  :key="index" 
  :data-index="index"
  @tap='curTime($event,item)'>{{item.TITLE}}</view>
curTime(e,item) {
  this.curItem = item;//這里item是一個就是想要的對象了
  this.curIndex = e.currentTarget.dataset.index;
 },
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

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