Maronato / vue-toastification

Vue notifications made easy!
https://vue-toastification.maronato.dev
MIT License
3.03k stars 139 forks source link

Fix cannot assign to read only property 'exports' (issue #335) #337

Open MelvinSnijders opened 2 years ago

MelvinSnijders commented 2 years ago

Description

Removed export keyword from the useToast() method.

Related Issue

335

Types of changes

Checklist:

dancing-bear-blues commented 2 years ago

I have been up and running for the last few days with this fix in place and do not have any side effects to report. I would like to see this change merged.

lukaszarpak commented 1 year ago

I found a solution.

Create your own composable and then use it the same way as described in the docs. Just make sure that vue-toastification/nuxt is added to modules in nuxt.config.js so it's injected into useContext().app.


Add these:

./nuxt.config.js

modules: [
    'vue-toastification/nuxt',
]

./composables/useToast

import { useContext } from '@nuxtjs/composition-api'

export const useToast = () => useContext().app.$toast

Usage:

import { useToast } from '@/composables/useToast'

// in setup()
const toast = useToast()

// use toast the same way as described in the docs