Answers for "laravel vuejs message box"

0

laravel vuejs message box

<template>
    <div class="alert alert-success" role="alert" v-show="show">
        {{ body }}
    </div>
</template>
    
<script>
    export default {
        props: ['message'],
        data() {
            return {
                show : false,
                body : ''
            }
        },
        created() {
            if(this.message) {
                this.flash(this.message)
            }
            window.events.$on('flash',(message) => this.flash(message))
        },
        methods: {
            flash(message) {
                this.show = true
                this.body = message
   
                setTimeout(() => {
                    this.hide()
                },3000)
            },
            hide() {
                this.show = false
            }
        }
    }
</script>
Posted by: Guest on August-28-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language