【问题标题】:Laravel-5.2 Css and js not working without assetLaravel-5.2 Css 和 js 在没有资产的情况下无法工作
【发布时间】:2019-02-24 07:35:14
【问题描述】:

我的 CSS 和 JS 文件位于 localhost 的公共文件夹中,但它不起作用。我使用 laravel 5.2。我尝试了很多方法,但仍然失败。

我不想使用 , <link href="{{asset('/css/app.css')}}" rel="stylesheet">

我用过:

<link href="public/css/app.css" rel="stylesheet">

但它不起作用。 请给我解决方案。我该怎么办?

谢谢。

【问题讨论】:

    标签: jquery html css laravel-5


    【解决方案1】:

    您首先需要在 public 文件夹中创建 assets 文件夹,然后将 css 文件夹和所有 css 文件放入其中,然后像这样链接它这个:

    <link href="assets/css/app.css" rel="stylesheet">
    

    希望对你有所帮助!

    更多view这个

    更新根据评论

    检查你的 .htaccess 文件使用这个

    <IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} !^/public/ 
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    
    RewriteRule ^(.*)$ /public/$1 
    #RewriteRule ^ index.php [L]
    RewriteRule ^(/)?$ public/index.php [L] 
    </IfModule>
    

    希望这项工作

    【讨论】:

    • 但是,这个项目创建了我们以前的开发人员。该项目已经创建并成功运行。我已经在本地设置了。他使用了,例如,&lt;script src="/public/assets/frontends/script/jquery.mixitup.js"&gt;&lt;/script&gt; 但如果没有更改,它就无法工作。这是可能的。请告诉我,我在做什么?
    • 您的意思是项目在现场正常工作但本地链接不起作用?
    • 是的,以前的开发人员使用过它并在运行中运行,但在我的选项中不工作。可以其他设置,我伪造的。
    • 检查更新并希望它对您有所帮助,也许您忘记更新您的 .htaccess 设置。
    • 抱歉,.htaccess 设置不起作用。我写了:&lt;IfModule mod_rewrite.c&gt; Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_URI} !^/public/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /public/$1 #RewriteRule ^ index.php [L] RewriteRule ^(/)?$ public/index.php [L] &lt;/IfModule&gt; 回复:**Not Found The requested URL /public/help was not found on this server. Apache/2.4.33 (Win64) PHP/7.2.4 Server at localhost Port 80**
    猜你喜欢
    • 1970-01-01
    • 2015-02-18
    • 2022-08-13
    • 2012-04-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-21
    • 2012-09-10
    • 1970-01-01
    相关资源
    最近更新 更多