ankurk91 / vue-toast-notification

Yet another toast notification plugin for Vue.js :tulip:
https://ankurk91.github.io/vue-toast-notification
MIT License
642 stars 76 forks source link

nuxt 3 module #83

Closed joseehilton147 closed 1 year ago

joseehilton147 commented 1 year ago

I'm submitting a ... (check one with "x")

[ ] Bug report => search github for a similar issue or PR before submitting
[x] Feature request
[ ] Other, please describe

Its possible to make this works on nuxt 3 as module or show us a integration using the new plugin system please.

ankurk91 commented 1 year ago

I have no idea of nuxt 3 and their plugin system

itskush commented 1 year ago

I got you Do this.

Create a file in your plugins folder such as toaster.ts paste the following in there:

import { useToast } from 'vue-toast-notification';
const toast = useToast();
export default defineNuxtPlugin(() => {
    return {
      provide: {
        toast,
      }
    }
});

in your nuxt.config.js add this to your css array 'vue-toast-notification/dist/theme-default.css'

to use the toaster in your component now do this

const { $toast } = useNuxtApp();
 $toast.success('You did it!');

have fun!!

coolpi21 commented 1 year ago

const { $toast } = useNuxtApp(); $toast.success('You did it!');

There will be an error in preview mode because named export 'useToast' not found.