var appAlerts = new Vue({ el: '#app-alerts', data: { alerts: [ ] }, mounted: function() { }, methods: { alert: function(type, message) { var app = this ; var index = this.alerts.length ; this.alerts.splice(index, 0, { display: false, type: type, message: message }); var functionDisplayAlert = function(app, index, display) { app.alerts[index].display = display ; } ; setTimeout(functionDisplayAlert, 500, app, index, true) ; setTimeout(functionDisplayAlert, 3000, app, index, false) ; } } });