Joomla 331 Uncaught ReferenceError:未定义jQuery

 罗帅飞1 发布于 2023-01-08 16:54

我突然开始收到以下错误:Uncaught ReferenceError:jQuery未定义.

我不是那么流利的PHP所以请善待.大声笑

我在index.php模板中的头代码是:
























includeInlineScripts() ?>

1 个回答
  • 这是因为你之后加载jQuery <jdoc:include type="head" />.你应该在这行之上加载jQuery甚至更好,使用以下代码:

    JHtml::_('jquery.framework');
    

    所以你最终的代码是:

    <head>
    <?php JHtml::_('jquery.framework'); ?>
    
    <meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width" />
    <link rel="shortcut icon" href="<?php echo $templateUrl; ?>/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans&amp;subset=latin" />
    <link rel="stylesheet" href="<?php echo $document->baseurl; ?>/templates/system/css/system.css" />
    <link rel="stylesheet" href="<?php echo $document->baseurl; ?>/templates/system/css/general.css" />
    <link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.css" media="screen" />
    <link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.responsive.css" media="all" />
    
    <!--[if lt IE 9]>
        <script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <!--[if lte IE 7]>
        <link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.ie7.css" media="screen" />
    <![endif]-->
    
    <jdoc:include type="head" />
    <script src="<?php echo $templateUrl; ?>/script.js"></script>
    <script src="<?php echo $templateUrl; ?>/script.responsive.js"></script>
    <script src="<?php echo $templateUrl; ?>/modules.js"></script>
    <?php $view->includeInlineScripts() ?>
    <script>if (document._artxJQueryBackup) jQuery = document._artxJQueryBackup;</script>
    

    你可能已经注意到了,我已经交换了一些东西,所以订单更清洁一点.

    另外,我还建议你删除这个:

    <!--[if lte IE 7]>
        <link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.ie7.css" media="screen" />
    <![endif]-->
    

    因为Internet Explorer非常老,所以不应该有任何理由支持它.

    希望这可以帮助

    2023-01-08 16:58 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有