Last active
June 29, 2018 14:31
-
-
Save bertoni/22ee84b9edfc4580aa8dc2dc3d3dc316 to your computer and use it in GitHub Desktop.
Vue-notification in the action VUEX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# src/vuex/actions.js | |
export default { | |
... | |
notify: (store, data) => { | |
Vue.prototype.$notify({ | |
group: (data.group || 'general'), | |
type: (data.type || 'warn'), | |
duration: (data.time || 6000), | |
speed: (data.speed || 1000), | |
text: (data.text || ''), | |
title: (data.title || null) | |
}) | |
}, | |
... | |
} | |
# src/components/MyComponent.vue | |
<template>...</template> | |
<script> | |
export default { | |
name: 'MyComponent', | |
data () { | |
return { | |
... | |
} | |
} | |
methods: { | |
someMethod () { | |
... | |
this.$store.dispatch('notify', {text: 'Some message of success', type: 'success'}) | |
... | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment