gpt4 book ai didi

laravel - 如何在 Laravel 5 中使用 ckeditor

转载 作者:行者123 更新时间:2023-12-02 17:59:05 25 4
gpt4 key购买 nike

我正在使用 laravel 创建一个新的博客 Web 应用程序。在此应用程序中,需要一个编辑器来创建博客文章,因此我使用 ckeditor 来实现此目的。

我已经使用官方 ckeditor 文档来安装和设置 ckeditor,但它没有在我的文本区域中显示编辑器。

这是我使用的脚本

<script src="/vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>
<script>
CKEDITOR.replace('article-ckeditor');
</script>

这是实现ckeditor

<div class="form-group">
{{Form::label('body', 'Body')}}
{{Form::textarea('body', $post->body, ['id' => 'article-ckeditor', 'class' => 'form-control', 'placeholder' => 'Body Text'])}}
</div>

这里我在控制台日志中发现了一些错误

Failed to load resource: the server responded with a status of 404 (Not Found)    (ckeditor.js:1)

Uncaught ReferenceError: CKEDITOR is not defined at create:108

运行 php artisanvendor:publish --tag=ckeditor 命令后,我收到了更多新错误。

Uncaught TypeError: Cannot read property 'unselectable' of null           (ckeditor.js:326 )
at b (ckeditor.js:326)
at a.<anonymous> (ckeditor.js:322)
at a.h (ckeditor.js:11)
at a.<anonymous> (ckeditor.js:13)
at a.window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.editor.CKEDITOR.editor.fire (ckeditor.js:14)
at a.fireOnce (ckeditor.js:13)
at a.window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.editor.CKEDITOR.editor.fireOnce (ckeditor.js:14)
at Object.<anonymous> (ckeditor.js:252)
at g (ckeditor.js:233)
at Object.load (ckeditor.js:233)

我正在创建一个博客应用程序,所以我需要一个编辑器,但它不起作用,我无法解决这个问题,因为它没有显示任何错误。除了这个编辑器之外,整个应用程序都是工作属性。

最佳答案

从错误来看,ckeditor.js 文件似乎未加载。

UniSharp/laravel-ckeditor的官方文档说你应该通过这个命令发布资源:

php artisan vendor:publish --tag=ckeditor

在该命令之后,您应该拥有以下文件:your_project_path/public/vendor/unisharp/laravel-ckeditor/ckeditor.js

更新:最后一个错误(无法读取 null 的“不可选择”属性)似乎是已知的 issue ckeditor 的默认 laravel app.js 中,他们建议从模板 app 中加载 app.js 的行中删除 defer .blade.php:

<script src="{{ asset('js/app.js') }}"></script>

关于laravel - 如何在 Laravel 5 中使用 ckeditor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57522544/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com