浏览代码

修改单选的删除问题

秦鹏 3 年之前
父节点
当前提交
77187486c5
共有 2 个文件被更改,包括 7 次插入5 次删除
  1. 2 2
      src/components/Adult/common/SingleModule.vue
  2. 5 3
      src/components/Adult/inputModules/Single.vue

+ 2 - 2
src/components/Adult/common/SingleModule.vue

@@ -91,7 +91,7 @@ export default {
   components: {
     Upload,
   },
-  props: ["curQueItem", "index", "changAnswer", "deleteOptionOne", "type"],
+  props: ["curQueItem", "index", "toIndex","changAnswer", "deleteOptionOne", "type"],
   data() {
     return {
       imgNumber: 10,
@@ -115,7 +115,7 @@ export default {
         cancelButtonText: "取消",
         type: "warning",
       }).then(() => {
-        this.deleteOptionOne(this.index);
+        this.deleteOptionOne(this.index,this.toIndex);
       });
     },
     //   修改正确答案

+ 5 - 3
src/components/Adult/inputModules/Single.vue

@@ -98,6 +98,8 @@
         <SingleModule
           :curQueItem="item"
           :index="index"
+          :toIndex="toIndex"
+
           :changAnswer="changAnswer"
           :deleteOptionOne="deleteOptionOne"
           :type="type"
@@ -347,12 +349,12 @@ export default {
       this.curQue.splice(index, 1);
     },
     // 删除其中一个选项
-    deleteOptionOne(index) {
-      if (this.curQue.option.length <= 2) {
+    deleteOptionOne(index, toIndex) {
+      if (this.curQue[toIndex].option.length <= 2) {
         this.$message.warning("至少要保留两个选项");
         return;
       }
-      this.curQue.option.splice(index, 1);
+      this.curQue[toIndex].option.splice(index, 1);
     },
     // 添加一个题
     addtopic() {