A
A
Analka2020-01-16 20:51:12
Vue.js
Analka, 2020-01-16 20:51:12

Laravel + Vue.js render template?

there is a code that monitors push notifications

const app = new Vue({
        el: '#app',
        data: function() {
            return {
                user:{
                    avatar: '',
                    username: '',
                    login: '',
                    slug: ''
                },
                message: {
                    text: '',
                    date: ''
                }
            }
        },
        mounted(){
            window.Echo.private('user_notif')
                .listen('UserNotification', (e) => {
                    //console.log(e);
                    this.AppenToBrowser(e);
                });
    
        },
        methods: {
            AppenToBrowser(data){
                console.log(data);
                let audio = new Audio('/sounds/push.mp3'); // path to file
                audio.play();
            }
        }
    });

how can I display such a div in the AppendToBrowser () method on the site, can I call the balde template and pass the data variable there?
<div class="notify">
        <div class="notif--header">
            {{ data.user.name }}
        </div>
        <div class="notif--body">
            {{ data.data.text }}
        </div>
    </div>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question