Handle errors on JS side in todo_app
parent
158184e0a6
commit
20e07ea032
@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<div class="toast fade" role="alert" aria-live="assertive" aria-atomic="true" data-bs-delay="5000" ref="elt">
|
||||
<div class="toast-header text-white bg-danger">
|
||||
<strong class="me-auto">Error</strong>
|
||||
<small class=""></small>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
<div v-for="msg in messages" :key="msg">
|
||||
{{ msg }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { Toast } from 'bootstrap'
|
||||
|
||||
defineProps({
|
||||
messages: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['closed'])
|
||||
|
||||
const elt = ref()
|
||||
let toastObject = null
|
||||
|
||||
onMounted(() => {
|
||||
toastObject = new Toast(elt.value)
|
||||
toastObject.show()
|
||||
elt.value.addEventListener("hidden.bs.toast", () => {
|
||||
emit('closed')
|
||||
})
|
||||
})
|
||||
</script>
|
Loading…
Reference in New Issue