Laravel Tailwind CSS - 工具提示未获取数据,但父级 div 获取数据
Laravel Tailwind CSS - Tooltip didn't get data, but parent div gets it
我有一个 table 出勤率,我只是将特定颜色传递给 div
和 id
出勤率,但我不明白一件事:id
像 <div id={{ attendance->id }}></div>
一样传递,但是当我传递其他数据时,就像我之前所做的那样,它只降低了一行,即使我在使用后清空了那个 var,它也会得到最新的?
@for ($i = 1; $i <= 30; $i++ )
@foreach ($user->attendances as $attendance)
@php
$temp = strtotime(Carbon\Carbon::parse(Carbon\Carbon::now())->startOfMonth()->setMonth(Carbon\Carbon::now()->month)->setDay($i)->format('Y-m-d'));
$start = strtotime(Carbon\Carbon::parse($attendance->start));
$end = strtotime(Carbon\Carbon::parse($attendance->end));
@endphp
@if ($temp >= $start && $temp <= $end)
@php
$user->cell = $attendance->id;
$user->style = $attendance->reasons->color;
@endphp
@endif
@endforeach
<td class="border border-slate-600">
<div data-tooltip-target="tooltip-default" class="rounded-md {{ $user->style }} py-2 px-3" style="background-color: {{ $user->style }}" id="{{ $user->cell }}"> <!-- Here it gives right value to each div -->
<div id="tooltip-default" role="tooltip" class="inline-block absolute invisible z-10 py-2 px-3 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 transition-opacity duration-300 tooltip dark:bg-gray-700">
ID attendance:{{ $user->cell }}<br> <!-- it gives the latest ID in DB. -->
<div class="tooltip-arrow" data-popper-arrow></div>
</div>
</div>
</td>
@php
$user->cell = '';
$user->style = '';
@endphp
@endfor
怎么解释呢?有没有更好的方法为 table 单元格中的每个 div 创建工具提示?
更新:
覆盖样式化可能会导致痛苦。但是,在 OP 情况下,无法在 class 属性中注入十六进制 rgb 值。
我有一个 table 出勤率,我只是将特定颜色传递给 div
和 id
出勤率,但我不明白一件事:id
像 <div id={{ attendance->id }}></div>
一样传递,但是当我传递其他数据时,就像我之前所做的那样,它只降低了一行,即使我在使用后清空了那个 var,它也会得到最新的?
@for ($i = 1; $i <= 30; $i++ )
@foreach ($user->attendances as $attendance)
@php
$temp = strtotime(Carbon\Carbon::parse(Carbon\Carbon::now())->startOfMonth()->setMonth(Carbon\Carbon::now()->month)->setDay($i)->format('Y-m-d'));
$start = strtotime(Carbon\Carbon::parse($attendance->start));
$end = strtotime(Carbon\Carbon::parse($attendance->end));
@endphp
@if ($temp >= $start && $temp <= $end)
@php
$user->cell = $attendance->id;
$user->style = $attendance->reasons->color;
@endphp
@endif
@endforeach
<td class="border border-slate-600">
<div data-tooltip-target="tooltip-default" class="rounded-md {{ $user->style }} py-2 px-3" style="background-color: {{ $user->style }}" id="{{ $user->cell }}"> <!-- Here it gives right value to each div -->
<div id="tooltip-default" role="tooltip" class="inline-block absolute invisible z-10 py-2 px-3 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 transition-opacity duration-300 tooltip dark:bg-gray-700">
ID attendance:{{ $user->cell }}<br> <!-- it gives the latest ID in DB. -->
<div class="tooltip-arrow" data-popper-arrow></div>
</div>
</div>
</td>
@php
$user->cell = '';
$user->style = '';
@endphp
@endfor
怎么解释呢?有没有更好的方法为 table 单元格中的每个 div 创建工具提示?
更新:
覆盖样式化可能会导致痛苦。但是,在 OP 情况下,无法在 class 属性中注入十六进制 rgb 值。