我的问题是我似乎无法在我的其他 View 上加载我的 .css 和 .js 文件。唯一可以访问 .css 和 .js 文件的 View 是我的 default_controller 的 index() 函数。目标文件夹没有任何问题,因为它可以通过索引功能访问。
我希望我的所有 View 都可以访问我的 .css 和 .js 文件。
最佳答案
将以下链接添加到您的头文件
<script src="<?php echo base_url() ?>js/hello.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="<?php echo base_url() ?>css/hello.css" type="text/css" charset="utf-8" />
对于 CSS
make the folder in codeigniter folder like following
codeigniter->css->hello.css
对于js
make the folder in codeigniter folder like following
codeigniter->js->hello.js
关于javascript - Codeigniter:如何从不同的 View 访问 css 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23263834/