我想为我的 ckeditor 启用只读模式,但是当我使用
enableReadOnlyMode
时不起作用。
import '../../../../public/assets/vendor/ckeditor5-41.2.0/build/ckeditor';
import CKEditor from '@ckeditor/ckeditor5-vue';
const Editor = ClassicEditor;
const ckeditor = CKEditor.component;
const editorConfig = {};
Editor.enableReadOnlyMode( 'my-feature-id' );
<ckeditor
class="ckeditor no-preflight"
id="ckeditor"
:editor="Editor"
v-model="form.description"
:config="editorConfig"
></ckeditor>
它在控制台中向我显示此错误:
Form.vue:32 Uncaught (in promise) TypeError: Editor.enableReadOnlyMode is not a function
一旦 ckeditor 准备好,就可以调用该函数,这可能不完全是在创建或安装 Vue 组件时,但编辑器本身会发出
ready
事件,您可以使用该事件来调用编辑器函数。
<ckeditor
id="ckeditor"
v-model="form.description"
class="ckeditor no-preflight"
:editor="Editor"
:config="editorConfig"
@ready="onReady"
></ckeditor>
function onReady(editor) {
editor.enableReadOnlyMode('my-feature-id')
}