2016-04-18 52 views
0

我有一個由CakePHP的3所產生這是基本結構的頁面:的JQuery 2.2.0錯誤

<!DOCTYPE html> 
<html> 
    <head> 
     <?= $this->Html->charset() ?> 
     <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> 
     <title> 
      Delta BEC | 
      <?= $this->fetch('title') ?> 
     </title> 
     <?= $this->Html->meta('icon') ?> 

     <?= $this->Html->css('bootstrap.min') ?> 
     <?= $this->Html->css('font-awesome.min') ?> 
     <?= $this->Html->css('custom') ?> 

     <?= $this->fetch('meta') ?> 
     <?= $this->fetch('css') ?> 
     <?= $this->fetch('script') ?> 
    </head> 
    <body> 
     <div class="wrapper"> 
      <?= $this->Flash->render() ?> 
      <?= $this->fetch('content') ?> 
     </div> 

     <?php $this->Html->script('../plugins/jQuery/jQuery-2.2.0.min.js'); ?> 
     <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script> 
     <script> 
      $.widget.bridge('uibutton', $.ui.button); 
     </script> 
     <?php $this->Html->script('bootstrap.min.js'); ?> 
     <?php $this->Html->script('app.min.js'); ?> 
    </body> 
</html> 

看着它,我沒有看到任何錯誤,但我雖然遇到這些錯誤:

jquery-ui.min.js:6 Uncaught ReferenceError: jQuery is not defined(anonymous function) @ jquery-ui.min.js:6(anonymous function) @ jquery-ui.min.js:6 
login:69 Uncaught ReferenceError: $ is not defined 

我在想什麼?

+0

這就是當你拉一個更快的時候會發生什麼。謝謝@Stryner! – Albert

+0

我對PHP不太熟練,所以我不確定。儘管我現在將它添加爲答案。 – Stryner

+0

在腳本標籤中使用'echo',例如<?php echo $ this-> Html-> script('../ plugins/jQuery/jQuery-2.2.0.min.js'); ?> –

回答

1

您不輸出腳本。

<?= $this->fetch('script') ?> 
    ^-- Implied echo 

<?php $this->Html->script('../plugins/jQuery/jQuery-2.2.0.min.js'); ?> 
    ^-- No implied echo => not included in resposne