Heim  >  Artikel  >  Backend-Entwicklung  >  php ci框架中加载css和js文件失败的解决方法_PHP

php ci框架中加载css和js文件失败的解决方法_PHP

WBOY
WBOYOriginal
2016-06-01 11:56:27855Durchsuche

CI框架

在将html页面整合到ci框架里面的时候,加载css和js失败,弄了半天发现ci框架是入口的框架,对框架中文件的所有请求都需要经过index.php处理完成,当加载外部的css和js文件的时候要使用base_url()函数处理外部的链接。

比如:

在config配置文件中的base_url为:" localhost:8080/项目名称/ "

在控制器中访问application/resource/aaa.js文件

相对路径访问失败

1、直接在src中输出



2、借用base标签

将base_url()的输出放在"/>标签里面,这样在

页面里面调用比较方便。
复制代码 代码如下:
"/>

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn