소스 검색

修复富文本编辑光标问题

306132416@qq.com 4 년 전
부모
커밋
db2d573e8c
2개의 변경된 파일23개의 추가작업 그리고 6개의 파일을 삭제
  1. 16 5
      src/components/wangEditor.vue
  2. 7 1
      src/views/notification/editPage/editPage.vue

+ 16 - 5
src/components/wangEditor.vue

@@ -12,13 +12,22 @@
         name: 'editor',
         data() {
             return {
-                unifiedUrl: "/lexus_php/api/"
+                unifiedUrl: "/lexus_php/api/",
+                editorContent: ''
             };
         },
-        props: ['content'],
+        props: ['catchData','content'],
         watch:{
-            'content':function (n) {
-                editor.txt.html(n);
+            // 'content':function (n) {
+            //     editor.txt.html(n);
+            // },
+            content:{
+                handler:function(newVal) {
+                    if (editor) {
+                        editor.txt.html(newVal);
+                    }
+                },
+                immediate: true,
             }
         },
         mounted() {
@@ -39,7 +48,9 @@
                 'location', // 位置
             ];
             editor.config.onchange = html => {
-                this.$emit('input', html);
+                // this.$emit('input', html);
+                this.editorContent = html;
+                this.catchData(this.editorContent); // 把这个html通过catchData的方法传入父组件
             };
             editor.config.uploadImgServer = php_url + this.unifiedUrl + 'upload.php';
             editor.config.uploadImgMaxSize = 10 * 1024 * 1024; // 将图片大小限制为 10M

+ 7 - 1
src/views/notification/editPage/editPage.vue

@@ -33,7 +33,7 @@
       <div class="Line Line4">
         <span>信息配置:</span>
         <div class="fuWenBen">
-          <editor-bar v-model="contentParam.content" :content="this.contentParam.content"></editor-bar>
+          <editor-bar v-model="contentParam.content"  :catchData="catchData" :content="this.contentParam.content"></editor-bar>
         </div>
         <div style="clear: both; display: block"></div>
       </div>
@@ -96,10 +96,14 @@ export default {
       delFileIds: [],
       editFileLength: "",
       allDataNameList: [],
+      htmlData:''
     };
   },
   computed: {},
   methods: {
+    catchData(content) {
+      this.htmlData = content;
+    },
     addNotice(id) {
       let requestURL, paramData;
       this.checkName();
@@ -108,6 +112,7 @@ export default {
         return;
       }
       if (!this.tipFlag) {
+        this.contentParam.content = this.htmlData;
         if (id) {
           //编辑
           requestURL = "notice_update.php";
@@ -272,6 +277,7 @@ export default {
   mounted() {
   //  this.getDataList();
     this.contentParam = JSON.parse(localStorage.getItem('nowPageEdit'));
+    console.log(this.contentParam)
     this.noticeId = this.contentParam.id;
     if (this.contentParam.files) {
       this.editFileLength = this.contentParam.files.length;