当Admin类加载默认索引()时调用。css和js加载在仪表板视图,但当我加载postadd_post css, js和图像不加载。我将相同的代码放在两个视图文件上。Dashboard和add_post这是我的控制器。
class Admin extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->view('dashboard');
}
public function Post()
{
$this->load->view('add_post');
}
}
config。
$config['base_url'] = 'http://localhost/timesofeducation';
autoload.php
$autoload['helper'] = array('url', 'form', 'html', 'captcha', 'string');
当我加载index() css url显示时检查元素。http://localhost/timesofeducation/css/style.css
,但当我加载。post()查看元素时显示的css url。http://localhost/timesofeducation/Admin/css/style.css
Admin自动添加的类。
base_url中缺少/
。试试这个
$config['base_url'] = 'http://localhost/timesofeducation/';
确保你使用了资源链接,比如
<?php echo base_url('css/style.css');?>