acidjazz / tv-toast

Programmatic toasts for Nuxt.js powered by Tailwind CSS
MIT License
116 stars 11 forks source link

Cannot read property 'show' of undefined #18

Closed productdevbook closed 3 years ago

productdevbook commented 3 years ago

ssr: true, yarn build and yarn start problem

yarn dev some problem

Screen Shot 2021-03-01 at 22 22 00 Screen Shot 2021-03-01 at 22 22 07

acidjazz commented 3 years ago

I think I need to see more of the code, the plugin isn't really made to render via SSR since its programmatic, maybe check for process.client? did you try running this in the browser?

productdevbook commented 3 years ago

yes browser problem

Screen Shot 2021-03-02 at 06 33 09
productdevbook commented 3 years ago

used onMounted in code fixed.

onMounted(() => {
      context.app.$toast.show({
        type: 'danger',
        title: 'Error',
        message: 'Please specify an e-mail address',
      })
    })
acidjazz commented 3 years ago

@productfrontenddeveloper you just need to use this.$toast.show and use mounted()