[Vuejs]-How to auto close a customized vue toast component

1👍

Try to use toast component with v-model directive. In toast you may use timer to emit hide event:

setTimeout(() => this.$emit('input'), 3000);

On the parent component you may use this one:

<toast-component v-model="isVisible"></toast-component>

Or without v-model sugar:

<toast-component :value="isVisible" @input="isVisible = false"></toast-component>

Leave a comment