2017-05-18 54 views
-1

如何在codeigniter中包含jQuery和引導庫? 我是新與笨,試圖觀看YouTube的一些影片,但沒有,感謝üCodeigniter,Jquery,Bootstrap

+3

可能重複的[包含css js在codeigniter的查看頁面](http://stackoverflow.com/questions/17060736/include-css-js-in-view-page-of-codeigniter) – Woodrow

+0

你試過使用'em在reglar html文件? – Ukasyah

+0

你在config.php中設置了base_url嗎? – ImBS

回答

0

這裏是你可以做什麼:

  1. 首先要確保已經安裝和工作CodeIgniter的框架,首先你必須看到框架的「歡迎頁面」,並且必須下載jQuery和Bootstrap的文件。之後,你必須在application/views文件夾中創建你的視圖,例如'home.php'文件。

  2. 然後嘗試,以顯示與HTML代碼視圖在瀏覽器中,在主控制器發生的下一行:

    class Inicio extends CI_Controller { 
    
        public function __construct() 
        { 
         parent::__construct(); 
        }// 
    
    
        public function index() 
        { 
         $this->load->view('home'); // The final path file of the view is application/views/home.php 
        } 
    } 
    
  3. 在您的視圖文件(home.php)你必須調用所需文件加載jQuery和引導,例如:

    <!DOCTYPE html> 
    <html lang="es"> 
    <head> 
        <meta charset="utf-8" /> 
        <base href="http://yourdomain.com/"> 
        <!-- Bootstrap --> 
        <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
        <script src="bootstrap-3.3.5-dist/js/bootstrap.min.js"></script> 
        <link rel="stylesheet" href="bootstrap-3.3.5-dist/css/bootstrap.css"> 
        <!-- jQuery --> 
        <script src="js/jquery-2.1.1.js"></script> 
    </head> 
    
  4. 這一點,如果你的路是正確的,該文件被加載後。

因此,我建議您閱讀starter tutorial of CodeIgniter (click here),您可以先試驗控制器和視圖。

jQuery和Bootstrap的路徑可能因您下載的版本而異。