Livewire là gì

Cơ quan chủ quản: Công ty cổ phần Truyền thông Việt Nam.
Địa chỉ: Tầng 16 VTCOnline, 18 Tam Trinh, Minh Khai, Hai Bà Trưng, Hà Nội
Điện thoại: 04-9743410. Fax: 04-9743413.

Liên hệ Tài trợ & Hợp tác nội dung
Hotline: 0942 079 358
Email:

Facebook

邮箱或手机号 密码

忘记帐户?

注册

无法处理你的请求

此请求遇到了问题。我们会尽快将它修复。

  • 返回首页

  • 中文(简体)
  • English (US)
  • 日本語
  • 한국어
  • Français (France)
  • Bahasa Indonesia
  • Polski
  • Español
  • Português (Brasil)
  • Deutsch
  • Italiano

  • 注册
  • 登录
  • Messenger
  • Facebook Lite
  • Watch
  • 地点
  • 游戏
  • Marketplace
  • Facebook Pay
  • Oculus
  • Portal
  • Instagram
  • Bulletin
  • 本地
  • 筹款活动
  • 服务
  • 选民信息中心
  • 小组
  • 关于
  • 创建广告
  • 创建公共主页
  • 开发者
  • 招聘信息
  • 隐私权政策
  • Cookie
  • Ad Choices
  • 条款
  • 帮助中心
  • 联系人上传和非用户
  • 设置
  • 动态记录

Meta © 2022

Building modern web apps is hard. Tools like Vue and React are extremely powerful, but the complexity they add to a full-stack developer's workflow is insane.
It doesn’t have to be this way...

Ok, I'm listening...

Say hello to Livewire.

Hi Livewire!

Livewire is a full-stack framework for Laravel that makes building dynamic interfaces simple, without leaving the comfort of Laravel.

Consider my interest piqued

It's not like anything you've seen before. The best way to understand it is to just look at the code. Strap on your snorkel, we're diving in.

...I'll get my floaties

Ok, let's see some code

Here's a real-time search component built with Livewire.

1use Livewire\Component;

2 

3class SearchUsers extends Component

4{

5 public $search = '';

6 

7 public function render()

8 {

9 return view('livewire.search-users', [

10 'users' => User::where('username', $this->search)->get(),

11 ]);

12 }

13}

App\Http\Livewire\SearchUsers.php

1<div>

2 <input wire:model="search" type="text" placeholder="Search users..."/>

3 

4 <ul>

5 @foreach($users as $user)

6 <li>{{ $user->username }}li>

7 @endforeach

8 ul>

9div>

resources/views/livewire/search-users.blade.php

You can include this component anywhere in your app like so.

1<body>

2 ...

3 @livewire('search-users')

4 ...

5body>

resources/views/welcome.blade.php

When a user types into the search input, the list of users updates in real-time.

Bonkers, I know...

How the he*k does this work?

  • Livewire renders the initial component output with the page (like a Blade include). This way, it's SEO friendly.
  • When an interaction occurs, Livewire makes an AJAX request to the server with the updated data.
  • The server re-renders the component and responds with the new HTML.
  • Livewire then intelligently mutates DOM according to the things that changed.