简体   繁体   English

CKeditor在Laravel中返回“未定义CKEditor”

[英]CKeditor return “CKEditor is not defined” in Laravel

When integrating CKeditor in Laravel. 在Laravel中集成CKeditor时。 It returns error: 它返回错误:

GET http://127.0.0.1:8000/control/post/vendor/unisharp/laravel-ckeditor/ckeditor.js net::ERR_ABORTED 404 (Not Found) GET http://127.0.0.1:8000/control/post/vendor/unisharp/laravel-ckeditor/ckeditor.js net :: ERR_ABORTED 404(未找到)

Uncaught ReferenceError: CKEditor is not defined at add:88 未捕获的ReferenceError:未在add:88定义CKEditor

This is my code: 这是我的代码:

<script src="vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>
<textarea id="editor1" ></textarea>

 <script>
     CKEDITOR.replace( 'editor1' );
 </script>

There are questions with the same problem, but none helped me 有相同问题的问题,但没有一个帮助我

You must first publish vendor with: 您必须首先通过以下方式发布供应商:

php artisan vendor:publish --tag=ckeditor

And then use the asset helper function to address the script file: 然后使用资产助手功能来寻址脚本文件:

  <script src="{{asset('vendor/unisharp/laravel-ckeditor/ckeditor.js')}}"></script>

or 要么

  <script src="/vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>

This happened because You forgot to add a forward slash before referencing the js file. 发生这种情况是因为您忘记了在引用js文件之前添加一个正斜杠。 this way browser addresses it from where your page currently at. 这样浏览器可以从您当前页面所在的位置对其进行寻址。 so use slash before the address or use the asset helper function 因此,请在地址前使用斜杠或使用资产助手功能

This should print out this: 这应该打印出来:

http://127.0.0.1:8000/vendor/unisharp/laravel-ckeditor/ckeditor.js (correct)

Instead of this: 代替这个:

http://127.0.0.1:8000/control/post/vendor/unisharp/laravel-ckeditor/ckeditor.js (wrong)

use this script <script src="https://cdn.ckeditor.com/4.5.6/standard/ckeditor.js"></script> and after your text area write 使用此脚本<script src="https://cdn.ckeditor.com/4.5.6/standard/ckeditor.js"></script>然后在您的文本区域中写上

 <script>CKEDITOR.replace( 'article-ckeditor' ); </script>

it will works with you 它会和你一起工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM