5 months ago

View components not loading

Posted 5 months ago by Amine-Barh

Hi, i'm trying to make a real-time chat service in my web app, i've followed the tutorial in pusher " " step by step, done it a couple of times actually but i got the same thing wrong twice, view components are not loading and so i can't test if the functionnality is actually working.. In the second try i've created a new layout that i am extending so that bootstrap classes do not get confused i thought, still nothing appears.

i'm extending this only for test puposes

<link rel="stylesheet" href="{{ asset('layout/styles/app.js') }}">

my chatmessages component

    <ul class="chat">
        <li class="left clearfix" v-for="message in messages">
            <div class="chat-body clearfix">
                <div class="header">
                    <strong class="primary-font">
                        {{ }}
                    {{ message.message }}

    export default {
        props: ['messages']

My chatform component

    <div class="input-group">
        <input id="btn-input" type="text" name="message" class="form-control input-sm" placeholder="Type your message here..." v-model="newMessage" @keyup.enter="sendMessage">

        <span class="input-group-btn">
            <button class="btn btn-primary btn-sm" id="btn-chat" @click="sendMessage">

    export default {
        props: ['user'],

        data() {
            return {
                newMessage: ''

        methods: {
            sendMessage() {
                this.$emit('messagesent', {
                    user: this.user,
                    message: this.newMessage

                this.newMessage = ''

My app.js (that i'm extending)

 * 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.


window.Vue = require('vue');

 * The following block of code may be used to automatically register your
 * Vue components. It will recursively scan this directory for the Vue
 * components and automatically register them with their "basename".
 * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>

Vue.component('example-component', require('./components/ExampleComponent.vue'));
Vue.component('chat-messages', require('./components/ChatMessages.vue'));
Vue.component('chat-form', require('./components/ChatForm.vue'));
// const files = require.context('./', true, /\.vue$/i)

// files.keys().map(key => {
//     return Vue.component(_.last(key.split('/')).split('.')[0], files(key))
// })

 * 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.

const app = new Vue({
    el: '#app',

    data: {
        messages: []

    created() {
            .listen('MessageSent', (e) => {
                    message: e.message.message,
                    user: e.user

    methods: {
        fetchMessages() {
            axios.get('/messages').then(response => {
                this.messages =;

        addMessage(message) {

  '/messages', message).then(response => {

My chat routes

Route::get('/chat', '[email protected]');
Route::get('messages', '[email protected]');
Route::post('messages', '[email protected]');

My chat view.blade



<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">Chats</div>

                <div class="panel-body">
                    <chat-messages :messages="messages"></chat-messages>
                <div class="panel-footer">


Here is a screenshot of my current view

I'm not that familiar with the code, i would really appreciate any help !

Please sign in or create an account to participate in this conversation.