【发布时间】:2021-02-11 07:33:02
【问题描述】:
我正在尝试将 Summernote 所见即所得与 Laravel 8 连接起来,无论我做什么,我都会收到一个持续的 jquery 错误。我尝试将 webpack 用于脚本并将脚本直接添加到页面中。我的脚本的顺序应该是正确的,我在脚本之后执行代码但是,该错误是一个基本错误,我无法确定问题。
webpack 文件是默认的,我已经运行了 npm run dev & prod。
列出的放入基本 HTML 文件的代码运行没有错误,我一定是在用 Laravel 做些什么。
jquery.js:4055 Uncaught TypeError: "#summernote".summernote is not a function
App.blade.php
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Scripts -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script type="text/javascript" rel="script" src="{{asset('js/app.js')}}" ></script>
<!-- Fonts -->
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
//rest of the template is out of the box Laravel base install with auth installed
<form method="post">
<textarea id="summernote" name="editordata"></textarea>
</form>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.js"></script>
<script type="text/javascript" rel="script" src="{{asset('js/main.js')}}" ></script>
</body>
</html>
Main.js
jQuery(document).ready(function() {
/* $('#summernote').summernote({
placeholder: 'Hello Bootstrap 4',
tabsize: 2,
height: 100 */
// Code still produces the error here
});
});
$('#summernote').summernote({
placeholder: 'Hello Bootstrap 4',
tabsize: 2,
height: 100
});
// Code still produces the error here
很高兴提供更多信息,我们将不胜感激。
【问题讨论】:
-
Summernote 对 jQuery 版本可能很挑剔。也许尝试他们的安装说明
3.4.1中提到的版本? github.com/summernote/summernote -
我没有收到任何错误。设置时
-
我已经尝试了 3.4.1 并且仍然得到错误。我可以使用上述版本的 jquery 在平面 html 中运行summernote note。 Laravel 肯定是在添加一些东西。
标签: javascript php jquery laravel