Przeglądaj źródła

调整editDiv不能中间输入问题

natasha 1 tydzień temu
rodzic
commit
e73f43555b

+ 4 - 2
src/components/Adult/phonePreview/AudioLine.vue

@@ -265,8 +265,10 @@ export default {
     handleError(res) {
       let audioId = this.audioId;
       this.$forceUpdate();
-      this.$refs[audioId].load();
-      this.PlayAudio();
+      if (this.$refs[audioId]) {
+        this.$refs[audioId].load();
+        this.PlayAudio();
+      }
     },
     // 点击 拖拽播放音频
     changeCurrentTime(value) {

+ 4 - 2
src/components/Adult/preview/AudioLine.vue

@@ -264,8 +264,10 @@ export default {
     handleError(res) {
       let audioId = this.audioId;
       this.$forceUpdate();
-      this.$refs[audioId].load();
-      this.PlayAudio();
+      if (this.$refs[audioId]) {
+        this.$refs[audioId].load();
+        this.PlayAudio();
+      }
     },
     // 点击 拖拽播放音频
     changeCurrentTime(value) {

+ 7 - 4
src/components/Adult/preview/EditDiv.vue

@@ -115,7 +115,7 @@ export default {
       this.lock = false;
       let id = "#" + this.id;
       document.querySelector(id).focus();
-      document.execCommand("selectAll", false, null);
+      // document.execCommand("selectAll", false, null);
       document.getSelection().collapseToEnd();
     },
     // 输入中文结束时
@@ -164,12 +164,15 @@ export default {
       }
     },
     // 文本输入框聚焦,焦点在最后位置
-    textFocus() {
+    textFocus(type) {
       let _this = this;
       setTimeout(() => {
         let id = "#" + _this.id;
         document.querySelector(id).focus();
-        document.execCommand("selectAll", false, null);
+        if (type === "tone") {
+          document.execCommand("selectAll", false, null);
+        }
+
         document.getSelection().collapseToEnd();
       }, 0);
     },
@@ -204,7 +207,7 @@ export default {
             e.target.innerHTML = str.trim();
             _this.fullContent = str.trim();
             _this.$emit("input", str.trim());
-            _this.textFocus();
+            _this.textFocus("tone");
           }, 10);
         }
       });