resources/views/filament/pages/question-management.blade.php)@use Illuminate\Support\Str 导入<x-math-render> 组件refresh-page 事件中添加数学公式重新渲染触发<td class="px-6 py-4" style="...">
{{ \Illuminate\Support\Str::limit($question['stem'] ?? 'N/A', 150) }}
</td>
<td class="px-6 py-4" style="...">
<x-math-render :content="Str::limit($question['stem'] ?? 'N/A', 150)" class="text-sm" />
</td>
app/Filament/Pages/QuestionManagement.php)use App\Livewire\Traits\WithMathRender;use WithMathRender; Traituse App\Livewire\Traits\WithMathRender;
class QuestionManagement extends Page
{
use WithMathRender;
// ...
}
$...$, $$...$$, \(...\), \[...\] 格式行内公式:
$f(x) = ax^2 + bx + c$$\alpha + \beta = \gamma$块级公式:
$$\int_0^\infty e^{-x^2} dx$$$$\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$常用数学符号:
$\frac{a}{b}$$\sqrt{x}$$x^2$$x_1$$\sum_{i=1}^{n}$$\int_a^b$$\lim_{x \to 0}${
"stem": "已知二次函数 $f(x) = ax^2 + bx + c$,求 $f(2)$ 的值。"
}
已知二次函数 f(x) = ax² + bx + c,求 f(2) 的值。
(数学公式会渲染成美观的数学符号)
@push('scripts')
<script src="/js/math-render.js"></script>
@endpush
@push('styles')
<link rel="stylesheet" href="/css/katex/katex.min.css">
@endpush
<x-math-render :content="Str::limit($question['stem'] ?? 'N/A', 150)" class="text-sm" />
Livewire.on('refresh-page', () => {
document.dispatchEvent(new Event('math:render'));
});
math:render 事件refresh-page 事件math:render 事件http://fa.test/admin/question-management$f(x) = ax^2 + bx + c$),会自动渲染为数学公式可能原因:
解决方案:
php artisan view:clear解决方案: 页面已配置自动刷新,如仍有问题:
// 在浏览器控制台中手动触发
document.dispatchEvent(new Event('math:render'));
🎉 题库管理页面现在已完全支持数学公式渲染!