【发布时间】:2020-04-13 04:37:30
【问题描述】:
我需要帮助。我正在使用 laravel、pusher 和 vuejs 开发实时通知。我试图从刀片模板中传递两个参数,但它们总是“未定义”
刀片模板:
<notification :userid="{{$user->IdUsuario}}" :unreads="{{$user->unreadNotifications}}"></notification>
Vuejs:
import NotificationItem from './NotificationItem.vue';
export default {
props: ['unreads', 'userid'],
components: {NotificationItem},
data() {
return {
unreadNotifications: this.unreads
}
},
mounted() {
console.log('Component mounted.');
Echo.channel('App.User.' + this.userid)
.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', function (e) {
console.log(e);
console.log(this.userid);
let newUnreadNotifications = {
data: {
IdSalida: e.IdSalida,
empleado: e.empleado,
status: e.status
}
};
this.unreads.push(newUnreadNotifications);
});
}
}
我不知道我做错了什么:(帮助!
【问题讨论】:
-
你试过在没有
:的情况下使用userid和unreads吗?