Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
laravel在通过URL传递值时不加载样式_Laravel_Url_Routes - Fatal编程技术网

laravel在通过URL传递值时不加载样式

laravel在通过URL传递值时不加载样式,laravel,url,routes,Laravel,Url,Routes,我使用的是Laravel5.4,当我用像http://localhost:8000/Music/{id},laravel不加载样式,但如果使用不带值的url来获取该视图,它会正确加载样式,如果像url的末尾添加了斜杠,它也不会加载样式http://localhost:8000/videos/但是没有斜杠http://localhost:8000/videos没问题。对不起,我英语说得不好 这是我的密码: Route::get('Music/{id}','homeController@Music'

我使用的是Laravel5.4,当我用像
http://localhost:8000/Music/{id}
,laravel不加载样式,但如果使用不带值的url来获取该视图,它会正确加载样式,如果像
url的末尾添加了斜杠,它也不会加载样式http://localhost:8000/videos/
但是没有斜杠
http://localhost:8000/videos
没问题。对不起,我英语说得不好

这是我的密码:

Route::get('Music/{id}','homeController@Music');

这可以通过路由模型绑定正常工作,并实现我想要的功能,但当它返回music blade文件时,它不会加载我链接的样式,但如果改用它:

Route::get('Music','homeController@Music');
a

那很好用。 由于URL中的{vlaues},我检查了很多方法 如果在URL末尾添加斜杠,它也不会加载样式或js文件


有什么问题吗?

我也在这台机器上测试过

<html>
<head>
    <link rel="stylesheet" href="css/test.css" type="text/css">
</head>
<body>
<div class="square"></div>
</body>
    </html>

使用asset()函数

<html>
   <head>
       <link href="{{ asset('css/test.css') }}" rel="stylesheet">
   </head>
   <body>
      <div class="square"></div>

   <!-- Same for Javascript... -->
   <script src="{{ asset('js/app.js') }}"></script>

   </body>
</html>


需要查看刀片模板以查看页面的呈现方式……以下是示例代码,我对其进行了测试,当我通过包含值的url获取样式或在其末尾添加斜杠时,它不会加载样式。但如果没有这些,它将加载样式这不是链接刀片模板中样式的正确方法…test.css文件夹在项目中的何处?它在public/css/test.css foldertry中
<html>
<head>
    <link rel="stylesheet" href="css/test.css" type="text/css">
</head>
<body>
<div class="square"></div>
</body>
    </html>
<html>
   <head>
       <link href="{{ asset('css/test.css') }}" rel="stylesheet">
   </head>
   <body>
      <div class="square"></div>

   <!-- Same for Javascript... -->
   <script src="{{ asset('js/app.js') }}"></script>

   </body>
</html>