euvl / vue-notification

:icecream: Vue.js 2 library for showing notifications
http://vue-notification.yev.io/
MIT License
2.39k stars 213 forks source link

Custom template not displaying any notification when triggered #225

Closed sts-ryan-holton closed 3 years ago

sts-ryan-holton commented 3 years ago

Describe the bug

When using the custom template slot, no notification is triggered even when calling this.$notify()

To Reproduce

  1. Add the following code to a Nuxt JS project's page
<template>
  <div>
    <notifications duration="-1">
      <template slot="body" slot-scope="{ item, close }">
        <pre>
          {{ item }}
        </pre>
      </template>
    </notifications>
  </div>
</template>

<script>
export default {
  created () {
    this.$notify({
      type: 'error',
      title: `Data Source Discovery Error`,
      text: `We're having some trouble fetching available data sources`,
      duration: 5000
    })
  }
}
</script>

Expected behavior

I should see a notification in the top right of my screen as this is the default behaviour

Screenshots

N/A

Desktop (please complete the following information):

Additional context

I have the plugin installed globally in my Nuxt JS project, and everything works fine if I just use the following:

<notifications classes="p-3 rounded-lg shadow bg-white text-md font-medium text-gray-800 m-3" duration="-1" />

However, I need to customise the HMTL content of a notification, thus the utilisation of slots and template. Why isn't it triggering?

lamphanqg commented 3 years ago

In my case, when I use this.$notify in created or mounted, I had to setTimeout for about 1 second to trigger it.

  mounted() {
    setTimeout(() => {
      this.$notify({
        type: "success",
        text: "test",
        duration: 3000,
      });
    }, 1000);
  },
justinforlenza commented 3 years ago

Im also having this issue. I tried using the example shown here. However it just caused no more notifications to show.

The solution proposed by @lamphanqg does not solve it for me, as I am not calling this.$notify in created or mounted

Im-Fran commented 3 years ago

I'm having the same issue, here is my template file: https://paste.theprogramsrc.xyz/emadugawuy.xml

github-actions[bot] commented 3 years ago

Stale issue message