只有指数函数控制器

只有指数函数控制器

问题描述:

我有两个功能的控制器,如下只有指数函数控制器

<?php 
defined('BASEPATH') OR exit('No direct script access allowed'); 

class User extends CI_Controller { 

    public function __construct() { 
     parent::__construct(); 
     $this->load->model('User_model'); 
    } 

    public function index() { 
     $this->load->view('registration/index'); 
    } 

    public function login() { 
     $this->load->view('registration/index'); 
    } 

,并在header.php文件下列容器内工作

<li class="nav-item"> 
    <a class="nav-link" href="<?php echo site_url("user/login")?>">Login</a> 
</li> 
<li class="nav-item"> 
    <a class="nav-link" href="<?php echo site_url("user")?>">Register</a> 
</li> 

我的问题是,当我点击注册按钮site_url('user'),其工作正常,但当我点击登录按钮与site_ur('user/login')我的CSS没有加载。对于这两个函数,我都尝试了相同的观点。但后来出现问题。 任何人都可以帮我解决我的配置错误吗?查看文件夹的我的文件结构是:

- views 
    -registration 
    -index.php 
    -index_script.php 
    templates 
    -header.php 
    -footer.php 
    -html_header.php 

index.php文件已经

<?php $this->load->view("templates/html_header"); 
$data = array(); 
$data["additional_script"] = $this->load->view("registration/index_scripts", array(), true); 
$this->load->view("templates/footer", $data); 

?> 

html_header.php包含

<!-- include angular js --> 
<script src="libs/angular/angular.min.js"></script> 

<link href="libs/bootstrap/css/bootstrap.min.css" rel="stylesheet" /> 
<link href="assets/css/clean-blog.min.css" rel="stylesheet"> 

<?php $this->load->view("templates/header")?> 

header.php

+0

告诉我们,你必须包括CSS –

+0

@ B.Desai我有我所有的引导,内部应用程序/视图/模板/ header.php文件, 应用程序/视图/模板/ footer.php –

+0

jQuery的链接检查浏览器的JS控制台并查看它尝试从哪个路径加载。 – ourmandave

您正在使用的URL不正确。您必须将<?php echo base_url(); ?>添加到脚本src。

对于如:<script src="<?php echo base_url(); ?>libs/angular/angular.min.js"></script>

也许这可以工作。

+0

您是否从Codeigniter项目中的URL中删除了index.php? 如果不添加 index.php /剩余的URL – Prabhu

+0

谢谢你是我的错误 –

+1

非常欢迎你。请接受我的答案,如果它帮助你。 – Prabhu