【问题标题】:Failed to load resource: the server responded with a status of 404 (Not Found) Laravel blade加载资源失败:服务器响应状态为 404 (Not Found) Laravel 刀片
【发布时间】:2021-12-13 01:12:16
【问题描述】:

我遇到了一个特殊的错误。所有前端视图功能齐全,所有源代码均已加载,但无法加载查看具有特定 ID 的帖子。

这是我为它定义的路线

Route::get('/posts/{id}/view', [\App\Http\Controllers\Frontend\PostController::class, 'view'])->name('posts.view');

这是用户点击标题时的查看页面,它将被重定向到post.view

<a id="ctl01_dlNews1_Link1_0"  class="FBMitra" style="color:#DBA63C;font-size:20px;font-weight:bold;" href={{route('posts.view',$post->id)}} >{{$post->title}}</a>

【问题讨论】:

  • 我认为您缺少 href 中的引号...尝试href="{{route('posts.view',$post-&gt;id)}}"
  • 没有href没问题,我找到了解决方案。

标签: laravel laravel-blade


【解决方案1】:

幸运的是,我在测试不同的路线和方法 1 天后找到了答案,我修复了错误,该错误与导致浏览器以 quirk 模式加载的 html 代码有关,这里是修复前 html 代码的头部:

这是防止浏览器加载到导致 js、css 或 bootsrap 无法加载的怪异模式的解决方案: https://web.dev/doctype/?utm_source=devtools

【讨论】:

    猜你喜欢
    • 2017-04-26
    • 2018-06-08
    • 2021-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多