],
生成事件類、監聽類
php artisan event:generate
事件類blo**iew
中寫入要觸發的事件
事件監聽類<?php
use illuminate\broadcasting\channel;
use illuminate\queue\serializesmodels;
use illuminate\broadcasting\privatechannel;
use illuminate\broadcasting\presencechannel;
use illuminate\foundation\events\dispatchable;
use illuminate\broadcasting\interactswithsockets;
use illuminate\contracts\broadcasting\shouldbroadcast;
use illuminate\support\facades\event;
class blo**iew
/*** get the channels the event should broadcast on.
** @return \illuminate\broadcasting\channel|array
*/public function broadcaston()
}
blo**iewlistener
中寫入事件觸發後的邏輯
控制器中繫結事件<?php
use illuminate\queue\interactswithqueue;
use illuminate\contracts\queue\shouldqueue;
class blo**iewlistener
/*** handle the event.
** @param blo**iew $event
* @return void
*/public function handle(blo**iew $event)
}
$article = article::find($id);
event::fire(new blo**iew($article));
注:繫結事件名在三個類中要一致
事件物件event
1.e.client 相對於當前頁面 視窗,不是這個元素 可視區域的左頂點 document.onmousemove function e 2.e.screen 相對於計算機螢幕的左頂點 document.body.onclick function e 3.offset 事件觸發時滑鼠距離該元素左邊...
事件物件(event)
再觸發dom上的某個事件時,會產生乙個事件物件event,這個物件中包含著所有與事件有關的資訊。所有瀏覽器都支援event物件,但支援的方式不同。1.事件物件的獲取 event的獲取 event內容重要內容 2.screenx pagex和clientx的區別 3.pagey和pagex的相容寫法 ...
Event事件詳解
首先提到event,先要明白event的產生,也要先明白焦點,什麼是焦點。焦點 使瀏覽器能夠區分使用者輸入的物件,當乙個元素有焦點的時候,那麼他就可以接收使用者的輸入。我們可以通過一些方式給元素設定焦點。而並不是所有元素都能夠接收焦點的,能夠響應使用者操作的元素才有焦點。例如 text 說到inpu...