【问题标题】:view not found exception-laravel查看未找到异常-laravel
【发布时间】:2022-01-11 07:03:21
【问题描述】:

View [cart] not found. {"exception":"[object] (InvalidArgumentException(code: 0): View [cart] not found. at C:\\wamp\\www\\projects\\BBT\\vendor\\laravel\\framework\\src\\Illuminate\\View\\FileViewFinder.php:137)

我创建了一个notification 并尝试使用cart.blade.php 作为邮件模板,如下所示。但是我收到了上述错误。我已经尝试通过此链接清除缓存:https://stackoverflow.com/questions/17913929/laravel-view-not-found-exception

namespace App\Notifications;
class CartExpiryNotification extends Notification
{
    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->view('cart', ['cartTemplate' => 'cartTemplate']);
    }
}

cart.blade.php

{{$cartTemplate}}

cart.blade.php 存在于路径 C:\wamp\www\projects\BBT\vendor\laravel\framework\src\Illuminate\Notifications\resources\views\cart.blade.php 中。

【问题讨论】:

  • 视图应该放在/resources/views文件夹中,而不是/vendor/...文件夹中
  • @brombeer 好的。现在我将cart.blade.php 移动到文件位置C:\wamp\www\projects\BBT\resources\views\vendor\notifications\cart.blade.php 。仍然显示相同的错误
  • view('cart' ... 期望刀片文件驻留在 /resources/views 文件夹中 - 而不是其中的任何子文件夹。可能想阅读Creating & Rendering Views

标签: php laravel exception notifications laravel-8


【解决方案1】:

您的视图应该在以下根目录中

your_project_name/app/resources/views/cart.blade.php

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-09
    • 1970-01-01
    • 2015-11-28
    • 2019-05-12
    • 2016-06-02
    • 1970-01-01
    • 1970-01-01
    • 2019-09-11
    相关资源
    最近更新 更多