首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在具有弹性/惯性的组件中使用CKEditor

在具有弹性/惯性的组件中使用CKEditor
EN

Stack Overflow用户
提问于 2021-08-26 19:30:16
回答 1查看 104关注 0票数 0

我想在我的Laravel/惯性项目中使用Ckeditor,但是我不能让它工作。我在LaraTips上找到了一个教程,但它是为VueJS-2编写的。我正在使用使用VueJS-3的最新版本惯性。

我想在一个单独的组件中使用Ckeditor,它(某种程度上)可以工作,但我无法在编辑器中显示旧数据。我得到了一个错误"Uncaught (in promise) TypeError: Cannot read property 'setData‘of undefined at Proxy.modelValue (app.js:29)“我做错了什么?

这是我的组件:

代码语言:javascript
复制
<template>
    <ckeditor :editor="editor" v-model="text" :config="editorConfig"></ckeditor>
    
</template>

<script>
    import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
    export default {
        data() {
            return {
                text: "",
                editor: ClassicEditor,
                editorConfig: {
                    // The configuration of the editor.
                },
            }
        },
        props: {
            modelValue: {}
        },
        
        setup() {
            
        },
        watch: {
            modelValue: {
                immediate: true,
                handler(modelValue) {
                    this.text = modelValue;
                }
            },

            text(text) {
                this.$emit('update:modelValue', text);
            }
        },
    }
</script>

有什么建议吗?

EN

回答 1

Stack Overflow用户

发布于 2021-10-06 21:43:31

我正在做同样的教程(我正在使用vueJS-3)。

这可能对你有用:

在app.js include CKEditor中:

代码语言:javascript
复制
createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => require(`./Pages/${name}.vue`),
    setup({ el, app, props, plugin }) {
        return createApp({ render: () => h(app, props) })
            .use(plugin)
            .use( CKEditor)
            .mixin({ methods: { route } })
            .mount(el);
    },
});

在Components/CkEditor.vue中检查您发出的是什么,查找此this.$emit("input", text);

代码语言:javascript
复制
<template>
    <ckeditor :editor="editor" v-model="text" :config="editorConfig"></ckeditor>
</template>

<script>
import ClasicEditor from "@ckeditor/ckeditor5-build-classic";

export default {
    props: {
        value: {},
    },
    data() {
        return {
            text: "",
            editor: ClasicEditor,
            editorConfig: {
                // The configuration of the editor.
            },
        };
    },

    watch: {
        value:{
            inmediate: true,
            handler(value){
                this.text = value;
            }
        },
        text(text) {
            this.$emit("input", text);
        },
    },
};
</script>

如果这对你有效,请告诉我

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68944370

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档