uniapp小程序v-for循环绑定事件传值为undefined uniapp事件函数传参undefined
<view v-for="(comment, index) in comments" :key="comment.idGenerator">
<view
v-for="(reply, replyIndex) in comment.children"
:key="reply.id"
style="margin-top: 12px"
class="childrenClass"
>
<image
class="iconClass"
:src="getCommentzanIconSrc(reply.isThumbsUp)"
mode="aspectFit"
@click="toggleLikeComment(reply.idGenerator, reply.isThumbsUp)"
></image>
</view>
</view>
toggleLikeComment(id,bool){
console.log(id,bool) //第二层级是undefined
}
最后发现key值写错了。:key=“reply.id” 替换 :key=“reply.idGenerator”,就好了