nandi95 / vue-toastify

🔥 Simple, extendable, dependency free notification plugin. 🔥
https://vue-toastify.netlify.com/
MIT License
227 stars 12 forks source link

help to understand the beginner :) #2

Closed everything-is-going-to-be-okay closed 5 years ago

everything-is-going-to-be-okay commented 5 years ago

for example i have component.vue file

<template>
  <div>
    <vue-toastify :status="settings" />
    <button @click="clicked">click to show Toastify</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      settings: {
        title: "toastified!",
        body: "This is the body.",
        canTimeout: true,
        defaultTitle: true,
        duration: 1000
      }
    }
  },

  methods: {
    clicked() {
      // what code should I write to call toastify?
    }
  }
}
</script>

p.s. your component is amazing

nandi95 commented 5 years ago

To trigger a notification you can $emit an event with your defined evenhandler. Eg.:

EventBus.$emit('vtNotify', this.settings);

You can find a working example of this in the App.vue