The use of resource file paths in thinkphp5

The use of resource file paths
in thinkphp5 The reference of resource files in thinkphp5 is not the same as thinkphp3, but it is not troublesome
to define the required paths in the configuration file config.php first, such as resource root (public)/image (img)/ Style (css)/script (js) path, assuming your resource files are placed under public/static
Find 'view_replace_str', add
'__PUBLIC__'=>think\Url::build('/') to the array .'public/',
'__JSPATH__'=>think\Url::build('/').'public/static/js/',
'__CSSPATH__'=>think\Url::build('/').' public/static/css/',
'__IMGPATH__'=>think\Url::build('/').'public/static/img/',
then use css and js in html like this
{load file='__CSSPATH__a. css'}
{load file='__JSPATH__a.js'}
images can only be replaced with plain paths
<img src="__IMGPATH__a.jpg">
There is also a problem to note here, if you have put the entry file in the root directory, and also put the rewrite configuration file in this directory, this method is suitable for apache

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325431165&siteId=291194637
Recommended