错误:使用本地文件时,summernote不是函数

问题描述:

我有一个非常奇怪的问题。当我使用我的本地summernote文件加载文本编辑器时,“.summernote不是函数”发生了。但是,如果我使用cdn文件加载编辑器,一切都很顺利。这里是我的HTML标头代码:错误:使用本地文件时,summernote不是函数

<!DOCTYPE html> 
<html dir="ltr" lang="en"> 
<head> 
    <meta charset="UTF-8"/> 
    <title><?php echo $title; ?></title> 
    <base href="<?php echo $base; ?>"/> 
    <?php if ($description) { ?> 
     <meta name="description" content="<?php echo $description; ?>"/> 
    <?php } ?> 
    <?php if ($keywords) { ?> 
     <meta name="keywords" content="<?php echo $keywords; ?>"/> 
    <?php } ?> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/> 
    <link href="favicon.ico" rel="icon"> 
    <!-- include jquery --> 
    <script type="text/javascript" src="javascript/jquery/jquery-2.1.1.min.js"></script> 
    <!-- include libraries BS3 --> 
    <script type="text/javascript" src="javascript/bootstrap/js/bootstrap.min.js"></script> 
    <link href="stylesheet/bootstrap.css" type="text/css" rel="stylesheet"/> 
    <!-- include font-awesome--> 
    <link href="javascript/font-awesome/css/font-awesome.min.css" type="text/css" rel="stylesheet"/> 
    <!-- include datetimepicker--> 
    <script src="javascript/jquery/datetimepicker/moment.js" type="text/javascript"></script> 
    <script src="javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js" type="text/javascript"></script> 
    <link href="javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css" type="text/css" rel="stylesheet" media="screen"/> 
    <!-- include customer stylesheet--> 
    <link type="text/css" href="stylesheet/stylesheet.css" rel="stylesheet" media="screen"/> 
    <!--include customer js--> 
    <script src="javascript/common.js" type="text/javascript"></script> 

    <?php if ($styles) { ;?> 
     <?php foreach ($styles as $style) { ;?> 
      <link href="<?php echo $style;?>" rel="stylesheet"></link> 
     <?php } ;?> 
    <?php } ;?> 
    <?php if ($scripts) { ;?> 
     <?php foreach ($scripts as $script) { ;?> 
      <script href="<?php echo $script;?>" type="text/javascript"></script> 
     <?php } ;?> 
    <?php } ;?> 

<!-- <link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.2/summernote.css" rel="stylesheet">--> 
<!-- <script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.2/summernote.js"></script>--> 

我试图直接加载本地文件,而不是由PHP回显它们,但问题仍然存在。

我检查了每个href,没有死链接。

然后我在javascript文件夹下创建了一个名为test.html的纯HTML文件,并且使用本地文件加载了文本编辑器。

通过我使用的方式,框架是CI,文件结构是:

root 
├──javascript 
    ├──bootstrap 
    ├──jquery 
    ├──summernote 
    ├──font-awesome 
    ├──test.html 

我不认为你是包括以正确的顺序脚本。

当您从CDN加载,您的订单看起来是这样的:

<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.2/summernote.js"></script> 
<script src="javascript/common.js" type="text/javascript"></script> 

。 。 。这是合乎逻辑的,因为你要确保summernote在主JS代码执行时加载。

但是,您的PHP依赖关系管理代码注入了链接到本地​​文件后的标记。基本上,转储全部逻辑的客户的脚本之前太:

<?php if ($styles) { ;?> 
    <?php foreach ($styles as $style) { ;?> 
     <link href="<?php echo $style;?>" rel="stylesheet"></link> 
    <?php } ;?> 
<?php } ;?> 
<?php if ($scripts) { ;?> 
    <?php foreach ($scripts as $script) { ;?> 
     <script src="<?php echo $script;?>" type="text/javascript"></script> 
    <?php } ;?> 
<?php } ;?> 

<script src="javascript/common.js" type="text/javascript"></script> 

(另请注意,在你的PHP你的脚本标签代写href而不是src

+0

这是'href'问题。我把它改成'href'到'src',问题没有了。在我的情况下,订单是好的。谢谢你的语法检查:) – SSD