You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel登录页面报错View [pageTitle] not found求助

问题排查与解决

1. 视图找不到错误(View [back.layouts.auth-layout] not found)

你的布局文件名是auth-laout.blade.php(存在拼写错误,缺少字母y),但登录视图login.blade.php中引用的布局是back.layouts.auth-layout,两者名称不匹配,导致Laravel无法定位到布局文件。

解决方法:
将布局文件名从auth-laout.blade.php修改为auth-layout.blade.php,确保文件名与视图引用的名称完全一致。

2. 页面标题失效问题

login.blade.php中的第二行代码使用了错误语法:@extends('pageTitle', ...),@extends仅用于继承布局模板,设置页面标题需要用@section来填充布局中@yield('pageTitle')的内容。

解决方法:
将该行代码替换为正确的@section写法:

@section('pageTitle', isset($pageTitle) ? $pageTitle : 'Login')

或者使用闭合式写法:

@section('pageTitle')
    {{ isset($pageTitle) ? $pageTitle : 'Login' }}
@endsection

3. 额外优化:静态资源路径问题(路由前缀为admin时的潜在问题)

布局文件中使用了相对路径./back/...加载静态资源,当路由前缀为admin时,页面URL为/admin/login,相对路径会解析为/admin/back/...,导致资源加载失败。建议使用Laravel的asset()辅助函数生成绝对路径:

<!-- 修改前 -->
<link rel="shortcut icon" href="./back/CCS_logo.png">
<link rel="stylesheet" href="./back/css/bootstrap.min.css">
<script src="./back/script.js"></script>

<!-- 修改后 -->
<link rel="shortcut icon" href="{{ asset('back/CCS_logo.png') }}">
<link rel="stylesheet" href="{{ asset('back/css/bootstrap.min.css') }}">
<script src="{{ asset('back/script.js') }}"></script>

内容的提问来源于stack exchange,提问作者ItReallyHurtz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 23:15:20