vue事件委托
html: <div class="main" ref="mainheight" @click="clickChatWords"><div class="talkItem" v-for="(item, index) in chatData" :key=
·
html:
<div class="main" ref="mainheight" @click="clickChatWords">
<div class="talkItem" v-for="(item, index) in chatData" :key="index">
<div classs=’chatWords’>{{item}}</div>
</div>
</div>
js:
clickChatWords (e) {
if (e.target.className === 'chatWords') { // 判断仅当点击类名为‘'chatWords'’的时候触发
// ....
}
}
更多推荐
已为社区贡献22条内容
所有评论(0)