Vue.js2在使用Pusher时未触发事件

时间:2019-04-09 12:10:37

标签: laravel vuejs2

Vuejs在订阅并绑定了Pusher和Channel之后没有触发事件。

代码:

created()
{
    this.pusher = new Pusher('abcdefgh',{
        encrypted:true,
        cluster:'mt1',
    });
    console.log(this.pusher);
    let that = this;
    this.channel = this.pusher.subscribe('chat_chanel');
    this.channel.bind('chat_saved', function (data) {
        that.$emit('incoming_chat',data);
        //console.log('Herrrrrrrrrrrrreeeeeeeeeeeeeeeee');
    });
    console.log(this.channel);
    this.$on('incoming_chat',function (chatMessage) {
        this.incomingChat(chatMessage);
        console.log('Chat Message',chatMessage);
    });

    //console.log('Herrrrrrrrrrrrreeeeeeeeeeeeeeeee');

},

0 个答案:

没有答案