Browse Source

画板拖拽问题修改

natasha 4 ngày trước cách đây
mục cha
commit
88604937f8

+ 15 - 5
src/views/book/courseware/create/components/question/drawing/Drawing.vue

@@ -91,11 +91,16 @@ export default {
     },
   },
   mounted() {
-    document.querySelector('.background-img').addEventListener('mousemove', this.mouseMove);
+    document.querySelectorAll('.background-img').forEach((item) => {
+      item.addEventListener('mousemove', this.mouseMove);
+    });
     document.body.addEventListener('mouseup', this.mouseUp);
   },
   beforeDestroy() {
-    document.querySelector('.background-img')?.removeEventListener('mousemove', this.mouseMove);
+    document.querySelectorAll('.background-img').forEach((item) => {
+      item.removeEventListener('mousemove', this.mouseMove);
+    });
+    // document.querySelectorAll('.background-img')?.removeEventListener('mousemove', this.mouseMove);
     document.body.removeEventListener('mouseup', this.mouseUp);
   },
   methods: {
@@ -177,8 +182,10 @@ export default {
         startY: clientY,
         type,
       };
-
-      document.querySelector('.background-img').style.cursor = cursor;
+      document.querySelectorAll('.background-img').forEach((item) => {
+        item.style.cursor = cursor;
+      });
+      // document.querySelectorAll('.background-img').style.cursor = cursor;
     },
     /**
      * 鼠标移动
@@ -282,7 +289,10 @@ export default {
      */
     mouseUp() {
       this.data.drag.dragging = false;
-      document.querySelector('.background-img').style.cursor = 'auto';
+      // document.querySelectorAll('.background-img').style.cursor = 'auto';
+      document.querySelectorAll('.background-img').forEach((item) => {
+        item.style.cursor = 'auto';
+      });
     },
   },
 };