Answer the question
In order to leave comments, you need to log in
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();
}
}
});
<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 questionAsk a Question
731 491 924 answers to any question