doushi1900 2018-06-11 07:41
浏览 165
已采纳

Laravel将参数从Route传递到Controller分解页面

I am trying to pass a route variable to the controller and it breaks down the whole page because if I go to network tab, it's being fetched as a document.

Here is the function in the controller:

public function watch($id)
{
      //Some logic goes here
}

Here is my Route:

Route::get('/watch/{id}', "HomeController@watch");

and the page looks something like:

localhost:8040/mysite/public/watch/1J76wN0TPI4

Here is a screenshot of the page after it loads:

Please check this image

  • 写回答

1条回答 默认 最新

  • dosryjij88555 2018-06-11 07:56
    关注

    The problem is that your assets are being loaded incorrectly.

    Assets meaning JS and CSS files, your base template or your main blade file is probably linking directly to a source url, once you add the new url that becomes obsolete.

    example

    mysite.com/mycss.css
    

    The above being a css file in your main blade, and a lot of people develop this with a absolute url

    when you add the route watch/id the file is then reading like this

    mysite.com/watch/1/mycss.css
    

    That is the error

    In your blade template, reference all assets using the asset helper https://laravel.com/docs/5.6/helpers#method-asset

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!