我正在尝试在我的一个 Angular 应用程序中使用Editor.js,当我尝试配置标题、列表和其他块时,它给了我以下错误:
ERROR TypeError: Cannot read property 't' of undefined
at e.value (bundle.js:10)
at new e (bundle.js:10)
at e.value (editor.js:2)
at e.value (editor.js:2)
at e.value (editor.js:2)
at e.value (editor.js:2)
at e.value (editor.js:2)
at HTMLLIElement.<anonymous> (editor.js:2)
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:39680)
这是我的组件的代码片段。
import { Component, OnInit } from '@angular/core';
import EditorJS from '@editorjs/editorjs';
import Header from '@editorjs/header';
import List from '@editorjs/list';
@Component({
selector: 'app-editorjs',
templateUrl: './editorjs.component.html',
styleUrls: ['./editorjs.component.css']
})
export class EditorjsComponent implements OnInit {
editor;
constructor() { }
ngOnInit() {
this.editor = new EditorJS({
holder: 'editor-js',
tools: {
header: {
class: Header,
shortcut: 'CMD+SHIFT+H',
},
list: {
class: List,
inlineToolbar: true,
},
}
});
}
onSave() {
this.editor.save().then((outputData) => {
console.log('Article data: ', outputData)
}).catch((error) => {
console.log('Saving failed: ', error)
});
}
}
段落工具工作正常,只有在我尝试配置其余工具时才会出现错误。