在codeigniter中安装summernote时出现与jquery相关的错误

时间:2019-07-16 05:11:38

标签: codeigniter codeigniter-3 summernote

我在使用jquery时遇到问题,我不知道该怎么办

我遵循https://summernote.org/getting-started/

中的说明

我已将此代码插入head标签

<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script> 
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script> 
<link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote.js"></script>

然后将文本区域ID设置为summernote

    <div class="form-group col-md-8">
      <label>Content</label>
        <textarea id="summernote" style="height: 200px;" name="isi_informasi"><?= $konten ?></textarea>
    </div>

并将此功能代码插入正文标签的末尾

<script type="text/javascript">
   $(document).ready(function() {
      $('#summernote').summernote();
   });
</script>

我在控制台中收到此错误消息

jQuery.Deferred exception: $(...).summernote is not a function TypeError: $(...).summernote is not a function
    at HTMLDocument.<anonymous> (http://localhost/okifftuh/admin/createInformation/2:533:30)
    at mightThrow (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js:3583:29)
    at process (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js:3651:12) undefined

jQuery.Deferred.exceptionHook @ jquery.js:3860
process @ jquery.js:3655
setTimeout (async)
(anonymous) @ jquery.js:3689
fire @ jquery.js:3317
fireWith @ jquery.js:3447
fire @ jquery.js:3455
fire @ jquery.js:3317
fireWith @ jquery.js:3447
ready @ jquery.js:3920
completed @ jquery.js:3930

================================================ ======================

Uncaught TypeError: $(...).summernote is not a function
    at HTMLDocument.<anonymous> (2:533)
    at mightThrow (jquery.js:3583)
    at process (jquery.js:3651)

(anonymous) @ 2:533
mightThrow @ jquery.js:3583
process @ jquery.js:3651
setTimeout (async)
jQuery.readyException @ jquery.js:3868
(anonymous) @ jquery.js:3888
mightThrow @ jquery.js:3583
process @ jquery.js:3651
setTimeout (async)
(anonymous) @ jquery.js:3689
fire @ jquery.js:3317
fireWith @ jquery.js:3447
fire @ jquery.js:3455
fire @ jquery.js:3317
fireWith @ jquery.js:3447
process @ jquery.js:3671
setTimeout (async)
(anonymous) @ jquery.js:3689
fire @ jquery.js:3317
fireWith @ jquery.js:3447
fire @ jquery.js:3455
fire @ jquery.js:3317
fireWith @ jquery.js:3447
ready @ jquery.js:3920
completed @ jquery.js:3930

1 个答案:

答案 0 :(得分:0)

我认为这是jquery的summernote版本兼容性问题,请尝试分别使用JQuery 3.2.0Summernote 0.8.2版本:

<link href="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.js"></script> 
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script> 
<link href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.2/summernote.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.2/summernote.js" defer></script>

更详细的兼容性问题列表为here