Skip to content

Instantly share code, notes, and snippets.

@tno2007
Created October 3, 2022 08:54
Show Gist options
  • Save tno2007/b7d28e226b73a9503918f0db8abe0893 to your computer and use it in GitHub Desktop.
Save tno2007/b7d28e226b73a9503918f0db8abe0893 to your computer and use it in GitHub Desktop.
BootstrapVue Toast in composition API
<script setup lang="ts">
import { reactive } from "vue";
const toast = reactive({
message: "",
options: {
title: "",
},
visible: false,
});
const showToast = (
message: string = "",
options: any = { title: "BootstrapVue Toast" }
) => {
// set message text
toast.message = message;
// set options if any
if (options) {
toast.options = options;
}
// show toast
toast.visible = true;
};
</script>
<template>
<div>
<button @click="showToast('A toast in vue composition API!')">
Click me
</button>
<b-toast :title="toast.options.title" :visible="toast.visible">
{{ toast.message }}
</b-toast>
</div>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment