【CKeditor5】datacontroller-init-non-existent-root: Attempting to init data on a non-existing root

使用angular4+和CKeditor5,报错,报错就是提示要创建editor的dom元素不存在

  #editor

  [editor]="Editor"

  data=""

  [(ngModel)]="data"

  (change)="editorChange($event)"

  >

 



@ViewChild('editor') editorItem;

this.Editor.create(

      this.editorItem,{

        toolbar: ['imageUpload'],

      }

    ).then((result) => {

      console.log("success",result);

    }).catch((err) => {

      console.log("err",err);

    });

原因是ViewChild获取的editor返回是elementRef

改为这个this.editorItem.elementRef.nativeElement即可以

你可能感兴趣的:(【CKeditor5】datacontroller-init-non-existent-root: Attempting to init data on a non-existing root)