I'm trying to make a global function with help of plugin which it worked fine but i couldn't show my notification. I was doing my homework and i tried to not write everywhere those show notification methods, so I've searched and i found this solution and i managed to add plugin now i wan to use it in my component. here's the code :
AppNotifications.js
export default {
failedNotification(title, data) {
return this.$vs.notify({
title:title,
text:data,
color:'danger',
position:'bottom-center',
});
}
};
App.js
import Vue from 'vue'
import notifications from './Helpers/AppNotifications'
const plugin = {
install () {
Vue.notifications = notifications
Vue.prototype.$notifications = notifications
}
}
Vue.use(plugin)
const app = new Vue({
vuetify,
el: '#app',
render: h => h(App),
router
});
And in componenets when i use a button with @click="SomeMethod"
i use plugin like this :
this.$notifications.failedNotification('Test','Just Failed, yay')
So function work but i get this error
Error in v-on handler: "TypeError: Cannot read property 'notify' of undefined"
Since I'm in learning process i wasn't familiar with this issue and I've tried to import vue and notification component itself but didn't worked.
Edit 01 : Notification is belong to Vuesax library and it's already imported in App.js and it's working fine when i use it in vue components but it's not working when i use it in AppNotification.js