Home>Article>PHP Framework> Solve the problem that ThinkPHP styles cannot be loaded (CSS, JS)

Solve the problem that ThinkPHP styles cannot be loaded (CSS, JS)

藏色散人
藏色散人 forward
2021-01-04 17:37:38 3423browse

The followingthinkphpframework tutorial column will introduce to you how to solve the problem of ThinkPHP style failure to load (CSS, JS). I hope it will be helpful to friends in need!

1. Project entry file index.php


      

2. Add the following code to the project configuration file APP/Conf/config.php

'TMPL_PARSE_STRING' => array( '__PUBLIC__' =>__ROOT__.'/APP/Tpl/Public', '__JS__' => __ROOT__.'/APP/Tpl/Public/Js', '__CSS__' => __ROOT__.'/APP/Tpl/Public/Css', ),

Previously, the CSS configured here was'__CSS__' => __PUBLIC__.'/Css'Then there was the problem of being unable to load CSS
Solve the problem that ThinkPHP styles cannot be loaded (CSS, JS)

ROOTis a system constant, indicating the root directory address of the website. For example, my localhost is set to E:\www In this place, and then create the ThinkPHPbbs project in E:\www\ThinkPHPbbs, thenROOTindicates localhost/ThinkPHPbbs

JS settings are the same as

3 .Configure html
CSS:

JS :

The normal loading effect is as shown
Solve the problem that ThinkPHP styles cannot be loaded (CSS, JS)

The file structure is as shown in the figure
Solve the problem that ThinkPHP styles cannot be loaded (CSS, JS)
(The red crosses in front of some folders will not affect the entire operation, the editor is zend studio)

It is recommended that if you encounter a situation where the style cannot be loaded If there is a problem, you can check the path of the link. For example, I configured it as follows'__CSS__' => __PUBLIC__.'/Css'

If you check the web page elements, it will be displayed as follows
Solve the problem that ThinkPHP styles cannot be loaded (CSS, JS)

HerePUBLICis not parsed out

Configure it like later'__CSS__' => __ROOT__.'/APP/Tpl/Public/ Css'

View style
Solve the problem that ThinkPHP styles cannot be loaded (CSS, JS)

Parse normally

The above is the detailed content of Solve the problem that ThinkPHP styles cannot be loaded (CSS, JS). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete