CKEditor5 輸入文字時拼音和漢字同時輸入問題

 

  在使用 CKEditor5 + vue 時,出現輸入文字時,拼音和文字一塊兒輸入到編輯器到問題。與以前項目中使用 ckeditor 的區別是,此次項目是在 python 架構下局部引入 ckeditor ,寫法以下:html

html: vue

 

<ckeditor
              id="editor"
              class="notice-editor"
              :editor="editor"
              :config="editorConfig"
              @ready="onReady"
/>

  

vue.jspython

  

  緣由(摘自某同事大牛的解釋):

  v-model 本質上是實現了一個名叫 value 的 prop,而後有更新時會 emit 一個 input 信號。而後 ckeditor 同時還監聽了 value 這個 prop 的修改,也就是父組件若是更新了 value,ckeditor 會收到信號,同時進行一些處理(ckeditor 認爲外部更新了文檔內容,所以也更新本身的內容),因而致使了問題。架構

 

  解決方法:

  不使用 v-model ,使用官網(https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/frameworks/vuejs.html)提供的 @input 綁定事件,獲取編輯器的 value 則用 :value 的方式獲取,寫法以下:編輯器

<ckeditor
      id="editor"
      class="notice-editor"
     :editor="editor"
     :config="editorConfig"
     :value="notice.content"
     @ready="onReady"
     @input="onEditorInput"
/>
相關文章
相關標籤/搜索