Questions about loading css and js
iUnicorn
iUnicorn 2019-05-08 20:02:42
0
5
1195

Teacher, 10-2 Community front-end page_2 In this course, you used "/static/css/bootstrap.css" to load the style. Why did I get an error when I loaded it according to this path? The 'bootstrap.css' and 'js' files cannot be referenced correctly. Is the path defined in which configuration file, but I don't see you using constants such as "__PUBLIC__" or "__STATIC__". Baidu has tried many methods but has not been able to solve it. Please answer. Thank you very much! !

iUnicorn
iUnicorn

知识,成就梦想!

reply all (1)
Single

The path is definitely wrong. Your constant definition path is spliced into a relative path that is not the real path. Open F12 in Google Chrome to see the path of the console static file

  • reply Hello, thanks for the reply. The reference code I wrote in phpstrom is as follows: The path is correct, and PS does not prompt an error. However, the console in the browser will prompt an error message as follows: Failed to load resource: the server responded with a status of 404 (Not Found) /public/static/Bootstrap_4.1.1/dist/css/bootstrap.css:1 So I tried to use "constant" after Baidu, but it prompted that the path was wrong! !
    iUnicorn author 2019-05-09 17:37:17
  • reply All right! ! Solved, the path can only be written according to Teacher Zhu’s writing method, as follows: href="//m.sbmmt.com/static/css/bootstrap.css" src="/static/js/jquery-3.2.1.min.js" I can't find the reason for the time being. I can only attribute it to some settings of ThinkPHP that I haven't learned yet. I'll talk about it later.
    iUnicorn author 2019-05-09 21:21:03
  • reply If it is tp5, there is a place to set template constants. You can check the manual yourself.
    Single author 2019-05-10 08:36:42
  • reply In the configuration
    Single author 2019-05-10 08:37:05
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!