<div class="evntablecontent" @click="threatClick($event)">
<ul class="item">
<li v-for="(item, index) in rowsData" :key="index" class="rows">
<span style="width: 15%" :data-item="JSON.stringify(item)">{{
item.id
}}</span>
<span style="width: 45%" :data-item="JSON.stringify(item)">{{
item.name
}}</span>
<span style="width: 30%" :data-item="JSON.stringify(item)">{{
item.phone
}}</span>
</li>
</ul>
</div>
threatClick(e) {
let str =
typeof e.target.dataset.item === 'string'
? JSON.parse(e.target.dataset.item)
: e.target.dataset.item;
let item = str;
console.log(item);
}
vue 动态自定义属性 object值传递与获取 :data-item
最新推荐文章于 2024-05-04 23:19:14 发布