Просмотр исходного кода

拖拽方法会触发点击事件的bug修复

刘洋 1 год назад
Родитель
Сommit
3cdb1c7cde
2 измененных файлов с 3 добавлено и 7 удалено
  1. 0 7
      src/components/global/robot/index.vue
  2. 3 0
      src/directives/drag.js

+ 0 - 7
src/components/global/robot/index.vue

@@ -1,19 +1,12 @@
 <template>
   <div class="robot" v-if="canShow">
-    <!-- <t-tooltip content="试试点我提问~" theme="light"> -->
     <div
       class="robot-img-box"
       v-drag
       title="试试点我提问~"
       @click="visible = !visible"
     >
-      <!-- <img
-        class="robot-img"
-        src="../../../assets/imgs/jiqiren.png"
-        @click="visible = !visible"
-      /> -->
     </div>
-    <!-- </t-tooltip> -->
     <t-dialog v-model:visible="visible" :footer="false" width="800">
       <iframe
         src="https://qmth.echo-isoftstone.com/visitors-ui/pc"

+ 3 - 0
src/directives/drag.js

@@ -4,10 +4,12 @@ function startDrag(event) {
   const dy = event.clientY - el.offsetTop;
 
   function doDrag(e) {
+    el.style.pointerEvents = 'none';
     el.style.left = e.clientX - dx + 'px';
     el.style.top = e.clientY - dy + 'px';
   }
   function stopDrag() {
+    el.style.pointerEvents = null;
     document.removeEventListener('mousemove', doDrag);
     document.removeEventListener('mouseup', stopDrag);
   }
@@ -15,6 +17,7 @@ function startDrag(event) {
   document.addEventListener('mouseup', stopDrag);
 }
 const drag = (el, binding) => {
+  el.style.pointerEvents = null;
   el.addEventListener('mousedown', startDrag);
 };