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

WBOY
Release: 2016-06-01 11:56:27
Original
854 people have browsed it

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()的输出放在"/>标签里面,这样在

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!