반응형
Uncaughed TypeError: 라벨이 있는 푸셔를 구현하는 동안 콜백이 함수가 아닙니다.
간단한 채팅 어플리케이션을 만들고 있는데 푸셔에 접속할 때 이 오류가 발생하며 5.4를 사용하고 있습니다.
Uncaught TypeError: callback is not a function
at app.js:15350
at PresenceChannel.Dispatcher.emit (app.js:34417)
at PresenceChannel.handleEvent (app.js:35936)
at app.js:33001
at ConnectionManager.Dispatcher.emit (app.js:34417)
at message (app.js:36336)
at Connection.Dispatcher.emit (app.js:34417)
at message (app.js:35789)
at TransportConnection.Dispatcher.emit (app.js:34417)
at TransportConnection.onMessage (app.js:34320)
앱 데이터를 올바른 파일과 키에 넣었습니다.무슨 일이 일어나고 있는지 알 수 없습니다.에코 함수를 삭제해도 에러가 표시되지 않습니다.에러에 대해서 설명해 주실 수 있습니까?여기 프런트 엔드 파일 App.js가 있습니다.
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap');
/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
Vue.component('example', require('./components/Example.vue'));
Vue.component('chat-message', require('./components/ChatMessage.vue'));
Vue.component('chat-log', require('./components/ChatLog.vue'));
Vue.component('chat-composer', require('./components/ChatComposer.vue'));
const app = new Vue({
el: '#app',
data: {
messages: []
},
methods: {
addMessage(message){
// add to existing messages
this.messages.push(message);
// persist to the database
axios.post('/messages', message).then(response=>{
// do whatever
});
}
},
created(){
// axios uses promises so we could do .then
axios.get('/messages').then(response=>{
this.messages = response.data;
});
Echo.join('chatroom')
.here()
.joining()
.leaving()
.listen('MessagePosted', (e)=>{
console.log(e);
});
}
});
MessagePosted가 작성한 이벤트입니다.
<?php
namespace App\Events;
use App\Message;
use App\User;
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;
class MessagePosted implements ShouldBroadcast
{
public $message = new Message;
public $user = new User;
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(Message $message, User $user)
{
$this->message = $message;
$this->user = $user;
}
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
*/
public function broadcastOn()
{
return new PresenceChannel('chatroom');
}
}
방법here
,joining
그리고.leaving
콜백을 파라미터로 받아들입니다.파라미터에 대해 유형체크가 실행되어 함수인지 확인합니다.파라미터가 없기 때문에 콜백은 정의되지 않습니다.
Uncaught TypeError: callback is not a function
Echo.join('chatroom')
.here()
.joining()
.leaving()
.listen('MessagePosted', (e)=>{
console.log(e);
});
언급URL : https://stackoverflow.com/questions/43218702/uncaught-typeerror-callback-is-not-a-function-while-implementing-pusher-with-la
반응형
'programing' 카테고리의 다른 글
하위 Vue 프로젝트를 상위 Vue 프로젝트에 포함시키고 상위 Vue 스토어에 액세스합니다. (0) | 2022.08.13 |
---|---|
VueJS 아키텍처에 관한 고려사항 프로젝트:Vuex 구현 (0) | 2022.08.13 |
구성 요소에서 vuex 작업을 매핑할 수 없습니다. (0) | 2022.08.13 |
Vue 2 nextTick에 대해서 (0) | 2022.08.13 |
C의 main() 함수에 유효한 시그니처는 무엇입니까? (0) | 2022.08.13 |