1

我正在尝试为 laravel 自定义我的电子邮件模板。所以我发布了通知和邮件供应商。

resources/views/vendor/notifications/email.blade.php文件中,框架调用这样的组件

@component('mail::button')

mail::前缀代表什么?

我试图在resources/views/vendor/mail/mycomponent.blade.php. 所以我也称它为默认组件。

@component('mail::mycomponent')

这没用。这里的错误:

View [mycomponent] not found. (View: /resources/views/vendor/notifications/email.blade.php)

所以我的问题是前缀mail::指向哪里?我可以将它用于我自己的组件吗?

4

1 回答 1

4

当你这样做时,php artisan vendor:publish --tag=laravel-maillarvel 在resources/views/vendor/mail名为htmland中创建 2 个目录markdown

您需要将组件放在那里以确保它可以在电子邮件模板中访问。

如果要创建组件,则需要创建 2 个文件: resources/views/vendor/mail/html/mycomponent.blade.phpresources/views/vendor/mail/markdown/mycomponent.blade.php

Markdown 将具有数据和插槽,而 html 将具有要呈现的实际 html 结构。

mail::前缀是 Laravel 查找邮件组件的方式,它并不是像我们这样在刀片中真正的文件夹路径等layouts.default

有关更多详细信息,请参阅文档

于 2019-02-15T22:38:16.640 回答