[vue] vue-seamless-scroll 滚动到第二遍的时候不能进行点击的问题

问题:使用vue-seamless-scroll组件时,循环第一遍可以正常点击,之后不能够正常点击,触发不了点击事件.

解决办法:在vue-seamless-scroll外的父元素上添加点击事件,利用js的事件委托(通俗地来讲,就是把一个元素响应事件(click、keydown...)的函数委托到另一个元素)

使用(data-XXX)自定义属性

可以给每一层都加上

html 复制代码
<div class="rightBottom scroll__common" @click="clickProp($event)">
  <vue-seamless-scroll
    :data="equipmentList"
    :class-option="classOption"
    class="warp"
    style="width: 100%"
  >
    <div
      :class="getClass(item.equStatus)"
      v-for="(item, index) in equipmentList"
      :key="index"
    >
      <div
        class="deviceNum"
        @click="toDetail(item.id, item)"
        :data-id="JSON.stringify(item.id)"
        :data-index="index"
      >
        <span
          class="name"
          :data-id="JSON.stringify(item.id)"
          :data-index="index"
          >{{ item.name }}</span
        >
        <span
          class="num"
          :data-id="JSON.stringify(item.id)"
          :data-index="index"
          >{{ item.num }}</span
        >
      </div>
    </div>
  </vue-seamless-scroll>
</div>
js 复制代码
clickProp(event){
  let eid = event.target.dataset.eid;
  let index = event.target.dataset.eid
},

参考:

关于使用vue-seamless-scroll,滚动到第二遍的时候不能进行点击的问题记录

相关推荐
xiaofeichaichai4 小时前
Webpack
前端·webpack·node.js
问心无愧05134 小时前
ctf show web入门111
android·前端·笔记
唐某人丶4 小时前
模型越来越强,我们还需要 Agent 工程吗?—— 从价值重估到 Harness 实践
前端·agent·ai编程
智码看视界4 小时前
现代Web开发基础:全栈工程师的起航点
前端·后端·c5全栈
JS菌5 小时前
手写一个 AI Agent 全栈项目:从沙箱执行到子智能体的完整实现
前端·人工智能·后端
excel6 小时前
HLS TS 文件损坏的元凶:Git 提交与拉取
前端
Aphasia3116 小时前
https连接传输流程
前端·面试
徐小夕6 小时前
万字长文!千万级文档 RAG 知识库系统落地实践
前端·算法·github
梦梦代码精6 小时前
2026年PHP开源商城系统实测对比:架构、多商户、商用授权,谁才是真·省心?
vue.js·docker·架构·开源·代码规范