Home > php教程 > php手册 > php ci框架中加载css和js文件失败的原因及解决方法,

php ci框架中加载css和js文件失败的原因及解决方法,

WBOY
Release: 2016-06-13 09:28:06
Original
1046 people have browsed it

php ci框架中加载css和js文件失败的原因及解决方法,

在将html页面整合到ci框架里面的时候,加载css和js失败,弄了半天发现ci框架是入口的框架,

对框架中文件的所有请求都需要经过index.php处理完成,当加载外部的css和js文件的时候要使

用base_url()函数处理外部的链接。

比如:

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

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

相对路径访问失败

1、直接在src中输出

<script src= "<&#63;php echo base_url();&#63;>.resource/aaa.js"></script>
Copy after login

2、借用base标签

将base_url()的输出放在< base href = "<?php echo base_url();?>"/>标签里面,这样在

页面里面调用比较方便。

<base href = "<&#63;php echo base_url();&#63;>"/>
<script src= "resource/aaa.js"></script>
Copy after login

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template