Created
February 18, 2017 18:45
-
-
Save greemwahr/d915ad4f950d23953ba4e2d6d60bf6ce to your computer and use it in GitHub Desktop.
Vue component for desktop notification
This file contains 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
Vue.component('desktop-notificator', { | |
props: ['message', 'title'], | |
template: '<button v-on:click="notify()">??</button>', | |
methods: { | |
notify: function() { | |
if (Notification.permission !== "granted") { | |
Notification.requestPermission(); | |
} else { | |
new Notification(this.title, { | |
body: this.message, | |
}) | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment