[英]cant load css and javascript in codeigniter 3.0.4
我無法在視圖文件中加載css和js,我已經將它們添加到文件夾中,並且已經設置了我的基本URL,但是這些代碼正在與我在較低版本的codeigniter上執行的項目一起使用。 怎么了? 我的觀點:
<link href="<?php echo base_url()?>js/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
</br></br>
<div class="panel panel-primary" style=" width: 1050px; border-radius: 0">
<div class="panel-heading" style="border-radius: 0 ">user List <button data-toggle="tooltip" data-placement="bottom" title="Print Customer Order" style="border-radius: 0px;"type="button" class="btn btn-default" aria-label="Left Align">
<a href="<?php echo base_url() . 'admin/printlist/'; ?>">
Print List
</a>
</button> </div>
<div class="panel-body" style="border-radius: 0 ">
<table id="myTable" class="table table-bordered" >
<thead>
<tr>
<th>Surname</th>
<th>Name </th>
<th>Age</th>
<th>School</th>
<th>Course</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<?php foreach ($user as $users): ?>
<tr>
<td><?php echo $users->surname; ?></td>
<td><?php echo $users->name; ?></td>
<td><?php echo $users->age; ?></td>
<td><?php echo $users->school; ?></td>
<td><?php echo $users->course; ?></td>
<td><?php echo $users->email; ?></td>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script src="<?php echo base_url() ?>js/dataTables/jquery.dataTables.js"></script>
<script src="<?php echo base_url() ?>js/dataTables/dataTables.bootstrap.js"></script>
<script>
$(document).ready(function() {
$('#myTable').dataTable({
"aaSorting": [[0, "asc"]]
});
});
</script>
我做了一些研究,發現css文件的默認位置與Codigniter中的應用程序處於同一級別。 IE:
/css
/application
如果是這種情況,請先檢查此內容。 您可以在回顯前面使用一些簡單的../
來解決此問題。
我注意到的另一件事是,您的CSS文件位於js文件夾( js/dataTables/
)中? 也許這是快速復制/粘貼錯誤?
將CSS和JS文件夾放在項目文件夾的根目錄(應用程序級別)中。
我在項目中創建了“ assets”文件夾,並在其中放置了css和js文件夾。 一切正常。
資產/ JS / jquery.bootstrap-touchspin.js“> 我認為將<?php echo base_url()?>
替換為<?php echo base_url(); ?>
是錯誤的<?php echo base_url(); ?>
<?php echo base_url(); ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.