1<template>
2 <div class="alert alert-success" role="alert" v-show="show">
3 {{ body }}
4 </div>
5</template>
6
7<script>
8 export default {
9 props: ['message'],
10 data() {
11 return {
12 show : false,
13 body : ''
14 }
15 },
16 created() {
17 if(this.message) {
18 this.flash(this.message)
19 }
20 window.events.$on('flash',(message) => this.flash(message))
21 },
22 methods: {
23 flash(message) {
24 this.show = true
25 this.body = message
26
27 setTimeout(() => {
28 this.hide()
29 },3000)
30 },
31 hide() {
32 this.show = false
33 }
34 }
35 }
36</script>
37