Joomla 331 Uncaught ReferenceError:未定义jQuery

use*_*135 3 jquery joomla

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

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

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

<head>
<jdoc:include type="head" />
<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" />

<!-- Created by Artisteer v4.2.0.60623 -->


<meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width" />

<!--[if lt IE 9]><script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.css" media="screen" />
<!--[if lte IE 7]><link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.ie7.css" media="screen" /><![endif]-->
<link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.responsive.css" media="all" />
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans&amp;subset=latin" />
<link rel="shortcut icon" href="<?php echo $templateUrl; ?>/favicon.ico" type="image/x-icon" />

<script>if ('undefined' != typeof jQuery) document._artxJQueryBackup = jQuery;</script>
<script src="<?php echo $templateUrl; ?>/jquery.js"></script>
<script>jQuery.noConflict();</script>
<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>
Run Code Online (Sandbox Code Playgroud)

Lod*_*der 5

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

JHtml::_('jquery.framework');
Run Code Online (Sandbox Code Playgroud)

所以你最终的代码是:

<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>
Run Code Online (Sandbox Code Playgroud)

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

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

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

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

希望这可以帮助