Home > PHP Framework > ThinkPHP > What should I do if thinkphp's css reference does not come in?

What should I do if thinkphp's css reference does not come in?

藏色散人
Release: 2021-12-27 11:54:33
Original
2236 people have browsed it

Solutions for thinkphp css references not coming in: 1. Check the storage location of js, css, img and other files; 2. Modify the way to reference css to "".

What should I do if thinkphp's css reference does not come in?

The operating environment of this article: Windows 7 system, thinkphp v5.1 version, Dell G3 computer.

What should I do if the css reference of thinkphp does not come in?

thinkphp5 references external css and the js path is indeed correct. Why is there no response?

After working on it all morning, I found out the reason and share it with you. Let me explain it with a css example:
1. We As you know, the js, css, img and other files we write are placed in public/static.
Here is the specific location map:
What should I do if thinkphps css reference does not come in?
The three codes are as shown in the figure: index.html index.php index.css
html

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        p{
            color: red;
        }
    </style>
    <link rel="stylesheet" href="public/static/index.css">
</head>
<body>
<p>{$name}欢迎你</p>
</body>
</html>
Copy after login

php

<?php
namespace app\index\controller;

class Index
{
    public function index()
    {
    return view(&#39;index&#39;,[
        &#39;name&#39;=>&#39;帅哥&#39;,
    ]);
    }
}
Copy after login

css

p{
    background-color: #000088;
}
Copy after login

is like this, I use the most common link, through the picture above, Everyone knows that there is no problem.

Then we visit the local browser, it looks like thisWhat should I do if thinkphps css reference does not come in?
There is no blue background, indicating that the link is not used
Why? The path is not used correctly Ah?
Then I found out through research that first of all, the integration software I use is laragon. This is not the point. I will post the root directory I set to
What should I do if thinkphps css reference does not come in?
which is public, and then my link. It is , it should be changed to , so it is successful.
What should I do if thinkphps css reference does not come in?
As shown in the picture, there is a background color.
To sum up, the css is ineffective because of the wrong judgment of the root directory. I hope my explanation will be helpful to everyone.

Recommended learning: "The latest 10 thinkphp video tutorials"

The above is the detailed content of What should I do if thinkphp's css reference does not come in?. For more information, please follow other related articles on the PHP Chinese website!

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