Bladeren bron

不能中间输入问题

natasha 2 dagen geleden
bovenliggende
commit
bbc28c8b17
1 gewijzigde bestanden met toevoegingen van 7 en 4 verwijderingen
  1. 7 4
      src/components/Adult/phonePreview/EditDiv.vue

+ 7 - 4
src/components/Adult/phonePreview/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);
         }
       });