main.ts
1 2 3 4 5 6 7 8 9 10 11 |
import { createApp } from "vue"; import "./style.css"; import App from "./App.vue"; import Notifications from '@kyvg/vue3-notification'; const app = createApp(App); app.use(Notifications); // Mount the app app.mount("#app"); |
App.vue
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<template> <div id="app"> <button @click="showNotification">Show Notification</button> <!-- Notifications Component --> <notifications /> </div> </template> <script> import { useNotification } from '@kyvg/vue3-notification'; export default { name: 'App', setup() { const { notify } = useNotification(); const showNotification = () => { // Displaying a notification notify({ title: "Important message", text: "Hello user! This is a notification.", type: 'success', // You can change the type to 'warn', 'error', or 'info' duration: 5000, // Duration in milliseconds }); }; return { showNotification, }; }, }; </script> |