livewire-development by spatie/freek.dev
npx skills add https://github.com/spatie/freek.dev --skill livewire-development在以下情况时激活此技能:
wire: 指令(如 model、click、loading、sort、intersect)时使用 search-docs 获取详细的 Livewire 4 模式和文档。
{{ $assist->artisanCommand('make:livewire create-post') }}
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
{{ $assist->artisanCommand('make:livewire create-post --mfc') }}
{{ $assist->artisanCommand('make:livewire create-post --class') }}
{{ $assist->artisanCommand('make:livewire Posts/CreatePost') }}
使用 php artisan livewire:convert create-post 在单文件、多文件和基于类的格式之间进行转换。
| 格式 | 标志 | 结构 |
|---|---|---|
| 单文件组件 | 默认 | PHP + Blade 在一个文件中 |
| 多文件组件 | --mfc | 独立的 PHP 类、Blade 模板、JS 文件、测试文件 |
| 基于类 | --class | 传统的 v3 风格类 |
| 基于视图 | ⚡ 前缀 | 仅 Blade 模板,带函数式状态 |
以下内容在 Livewire 4 中已变更,但此应用程序中可能尚未更新。请验证此应用程序的设置以确保遵循现有约定。
Route::livewire();配置键已重命名:layout → component_layout,lazy_placeholder → component_placeholder。wire:model 现在默认忽略子事件(使用 wire:model.deep 获得旧行为);wire:scroll 重命名为 wire:navigate:scroll。wire:transition 现在使用 View Transitions API(修饰符已移除)。$wire.$js('name', fn) → $wire.$js.name = fn;commit/request 钩子 → interceptMessage()/interceptRequest()。@island)用于隔离更新;异步操作(wire:click.async,#[Async])用于并行执行。defer、lazy.bundle 用于优化组件加载。| 功能 | 用法 | 目的 |
|---|---|---|
| 独立更新区域 | @island(name: 'stats') | 隔离的更新区域 |
| 异步 | wire:click.async 或 #[Async] | 非阻塞操作 |
| 延迟 | defer 属性 | 页面渲染后加载 |
| 捆绑 | lazy.bundle | 多个组件一起加载 |
wire:sort、wire:intersect、wire:ref、.renderless、.preserve-scroll 可供使用。data-loading 属性会自动添加到触发网络请求的元素上。| 指令 | 目的 |
|---|---|
wire:sort | 拖放排序 |
wire:intersect | 视口交叉检测 |
wire:ref | 用于 JS 的元素引用 |
.renderless | 不渲染的组件 |
.preserve-scroll | 保持滚动位置 |
wire:keywire:loading 处理加载状态wire:model.live 进行即时更新(默认是防抖的)smart_wire_keys 默认为 true;新增配置:component_locations、component_namespaces、make_command、csp_safe。wire:transition 使用浏览器 View Transitions API;$errors 和 $intercept 魔术属性可用。wire:poll 和并行的 wire:model.live 更新提高了性能。关于拦截器和钩子,请参阅 reference/javascript-hooks.md。
Livewire::test(Counter::class) ->assertSet('count', 0) ->call('increment') ->assertSet('count', 1);
@foreach 循环上都有 wire:keywire:key → 意外的重新渲染wire:model 实时更新 → 使用 wire:model.live每周安装量
242
代码仓库
GitHub 星标数
644
首次出现
2026年2月3日
安全审计
安装于
opencode213
codex212
gemini-cli208
github-copilot204
amp195
kimi-cli195
Activate this skill when:
Use search-docs for detailed Livewire 4 patterns and documentation.
{{ $assist->artisanCommand('make:livewire create-post') }}
{{ $assist->artisanCommand('make:livewire create-post --mfc') }}
{{ $assist->artisanCommand('make:livewire create-post --class') }}
{{ $assist->artisanCommand('make:livewire Posts/CreatePost') }}
Use php artisan livewire:convert create-post to convert between single-file, multi-file, and class-based formats.
| Format | Flag | Structure |
|---|---|---|
| Single-file (SFC) | default | PHP + Blade in one file |
| Multi-file (MFC) | --mfc | Separate PHP class, Blade, JS, tests |
| Class-based | --class | Traditional v3 style class |
| View-based | ⚡ prefix | Blade-only with functional state |
These things changed in Livewire 4, but may not have been updated in this application. Verify this application's setup to ensure you follow existing conventions.
Route::livewire() for full-page components; config keys renamed: layout → component_layout, lazy_placeholder → component_placeholder.wire:model now ignores child events by default (use wire:model.deep for old behavior); wire:scroll renamed to wire:navigate:scroll.wire:transition now uses View Transitions API (modifiers removed).@island) for isolated updates; async actions (wire:click.async, #[Async]) for parallel execution.defer, lazy.bundle for optimized component loading.| Feature | Usage | Purpose |
|---|---|---|
| Islands | @island(name: 'stats') | Isolated update regions |
| Async | wire:click.async or #[Async] | Non-blocking actions |
| Deferred | defer attribute | Load after page render |
| Bundled | lazy.bundle | Load multiple together |
wire:sort, wire:intersect, wire:ref, .renderless, .preserve-scroll are available for use.data-loading attribute automatically added to elements triggering network requests.| Directive | Purpose |
|---|---|
wire:sort | Drag-and-drop sorting |
wire:intersect | Viewport intersection detection |
wire:ref | Element references for JS |
.renderless | Component without rendering |
.preserve-scroll | Preserve scroll position |
wire:key in loopswire:loading for loading stateswire:model.live for instant updates (default is debounced)smart_wire_keys defaults to true; new configs: component_locations, component_namespaces, make_command, csp_safe.wire:transition uses browser View Transitions API; $errors and $intercept magic properties available.wire:poll and parallel wire:model.live updates improve performance.For interceptors and hooks, see reference/javascript-hooks.md.
Livewire::test(Counter::class) ->assertSet('count', 0) ->call('increment') ->assertSet('count', 1);
wire:key on all @foreach loopswire:key in loops → unexpected re-renderingwire:model real-time → use wire:model.liveWeekly Installs
242
Repository
GitHub Stars
644
First Seen
Feb 3, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykPass
Installed on
opencode213
codex212
gemini-cli208
github-copilot204
amp195
kimi-cli195
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
106,200 周安装
$wire.$js('name', fn) → $wire.$js.name = fn; commit/request hooks → interceptMessage()/interceptRequest().