Unable to invoke ck-editor textarea (Uncaught TypeError: $(...).ckeditor is not a function)

Unable to invoke ck-editor textarea (Uncaught TypeError: $(...).ckeditor is not a function)

我正在使用 Laravel 5.7 和一个名为 laravel-ckeditor 的包,但我无法调用 ck-editor textarea。

我像这样将包和脚本包含在我的视图中(这将它们加载到我的文件底部,就在 </body> 标记上方):

@section('js')
  <script src="{{asset('js/render_select2.js')}}" charset="utf-8"></script>
  <script src="/vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>
  <script src="{{asset('js/render_ckeditor.js')}}" charset="utf-8"></script>
@endsection

文件ckeditor.js正在正确加载,我在查看页面源代码时可以打开它。

我什至将应用程序服务提供商添加到我的 app.php 文件并发布了资产。

jQuery包含在之前这个。 jQuery 有效,因为我可以在另一个脚本中毫无问题地使用它。文件 render_ckeditor.js 包含此行:

$('.ck-textarea').ckeditor();

这是文本区域:

<div class="row">
  <div class="col-sm-12">
    <div class="form-group">
      {{Form::label('description', 'Product description')}}
      {{Form::textarea('description', '', ['id' => 'ck-textarea', 'class' => 'form-control ck-textarea', 'style' => 'resize: vertical', 'placeholder' => 'Product description'])}}
    </div>
  </div>
</div>

我尝试使用 ID 而不是 class 来调用它,将我的 render_ckeditor.js 文件更改为:

$('#ck-textarea').ckeditor();

使用 ID 或 class 都导致此错误消息:

Uncaught TypeError: $(...).ckeditor is not a function at render_ckeditor.js:1

我在这里错过了什么?

原来我必须包含 jQuery 适配器(duhh..),完全忽略了额外的包含。

添加这个解决了它:

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