【问题标题】:How can I display two table in email layout laravel 5.4?如何在电子邮件布局 laravel 5.4 中显示两个表格?
【发布时间】:2018-02-13 05:00:03
【问题描述】:

我想自定义 Laravel 5.4 通知电子邮件模板

https://medium.com/@adnanxteam/how-to-customize-laravel-5-4-notification-email-templates-header-and-footer-158b1c7cc1c

在 vendor/mail/html/message.blade 上,我尝试这样:

@component('mail::layout')
    {{-- Header --}}
    @slot('header')
        @component('mail::header', ['url' => config('app.url')])
            {{ config('app.name') }}
        @endcomponent
    @endslot

    {{-- Body --}}
    This is table one
    @component('mail::table')
    | Laravel       | Table         | Example  |
    | ------------- |:-------------:| --------:|
    | Col 2 is      | Centered      | $10      |
    | Col 3 is      | Right-Aligned | $20      |
    @endcomponent

    This is table two
    @component('mail::table')
    | Laravel       | Table         | Example  |
    | ------------- |:-------------:| --------:|
    | Col 2 is      | Centered      | $10      |
    | Col 3 is      | Right-Aligned | $20      |
    @endcomponent

    {{-- Subcopy --}}
    @isset($subcopy)
        @slot('subcopy')
            @component('mail::subcopy')
                {{ $subcopy }}
            @endcomponent
        @endslot
    @endisset

    {{-- Footer --}}
    @slot('footer')
        @component('mail::footer')
            © {{ date('Y') }} {{ config('app.name') }}. All rights reserved.
        @endcomponent
    @endslot
@endcomponent

有 2 张桌子。第一个表看起来不错。但是第二张桌子,看起来并不整洁。似乎css不起作用。而除了表1之后的数据,文字都很小

邮件布局结果如下:

为什么会这样? 我的代码还是错了吗?

【问题讨论】:

  • 你能转储生成的 html 吗? 但第二张桌子,看起来不整齐有点模糊。是视觉上的吗?还是通过生成的代码?
  • @Bagus Tesa,我更新了我的问题
  • 嗯,很奇怪,注意到<div class="table"> 在那里吗?它不应该在那里吗?你能转储html吗?另外,尝试运行php artisan view:clear(对不起,自从我上次接触 Laravel 以来已经很久了,我正在寻找的功能是清除视图缓存的功能)。
  • 致有类似问题的任何人;我想添加表格的地方也有奇怪的 div 标签。它实际上很容易修复并且很有意义:Markdown 将所有缩进的内容解释为代码块。我需要做的就是不缩进任何东西。
  • @SuccessMan 你解决了吗?

标签: laravel email notifications laravel-5.4


【解决方案1】:

只需删除缩进,因为在编写 Markdown 电子邮件时。 Markdown 解析器会将缩进的内容呈现为代码块。

@component('mail::layout')
{{-- Header --}}
@slot('header')
    @component('mail::header', ['url' => config('app.url')])
        {{ config('app.name') }}
    @endcomponent
@endslot

{{-- Body --}}
This is table one
@component('mail::table')
| Laravel       | Table         | Example  |
| ------------- |:-------------:| --------:|
| Col 2 is      | Centered      | $10      |
| Col 3 is      | Right-Aligned | $20      |
@endcomponent

This is table two
@component('mail::table')
| Laravel       | Table         | Example  |
| ------------- |:-------------:| --------:|
| Col 2 is      | Centered      | $10      |
| Col 3 is      | Right-Aligned | $20      |
@endcomponent

    {{-- Subcopy --}}
    @isset($subcopy)
        @slot('subcopy')
            @component('mail::subcopy')
                {{ $subcopy }}
            @endcomponent
        @endslot
    @endisset

    {{-- Footer --}}
    @slot('footer')
        @component('mail::footer')
            © {{ date('Y') }} {{ config('app.name') }}. All rights reserved.
        @endcomponent
    @endslot
@endcomponent

【讨论】:

    猜你喜欢
    • 2017-08-01
    • 2018-02-12
    • 2018-02-24
    • 2019-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多