Heim  >  Fragen und Antworten  >  Hauptteil

Fragen zum Laden von CSS und JS

Lehrer, 10-2 Community-Frontend-Seite_2 In diesem Kurs haben Sie „/static/css/bootstrap.css“ zum Laden des Stils verwendet. Warum habe ich eine Fehlermeldung erhalten, als ich ihn gemäß diesem Pfad geladen habe? Auf die Dateien „bootstrap.css“ und „js“ kann nicht korrekt verwiesen werden. Ist der Pfad in welcher Konfigurationsdatei definiert, aber ich sehe keine Konstanten wie „__PUBLIC__“ oder „__STATIC__“. Baidu hat viele Methoden ausprobiert, konnte es aber nicht lösen. Bitte antworten Sie. Vielen Dank! !

iUnicorniUnicorn1966 Tage vor1227

Antworte allen(5)Ich werde antworten

  • Single

    Single2019-05-09 16:55:11

    肯定路径错误 你的常量定义路径拼接上相对路径并不是真实路径 谷歌浏览器打开F12看看控制台静态文件的路径

    Antwort
    0
  • iUnicorn

    你好,感谢回复。我在phpstrom中写的引用代码如下: 路径没错,PS也没有提示出错。但在浏览器中的控制台会提示出错信息如下: 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 所以我才百度后尝试使用“常量”,但就提示路径出错了!!

    iUnicorn · 2019-05-09 17:37:17
    iUnicorn

    好吧!!解决了,路径只能按朱老师的写法,如下: href="/static/css/bootstrap.css" src="/static/js/jquery-3.2.1.min.js" 暂时找不到原因,只能归结于ThinkPHP有些设置我还没学到,以后再说。

    iUnicorn · 2019-05-09 21:21:03
    Single

    如果是tp5的话有个设置模板常量的地方 你自己查查手册

    Single · 2019-05-10 08:36:42
    Single

    在配置里面

    Single · 2019-05-10 08:37:05
  • StornierenAntwort