I've created a service file named message.vue
<script>
export default {
methods:{
alert(msg,title){
this.$alertify.alert( title,msg);
}
}
}
</script>
Here's how I use it:
import messageSvc from '@/shared/services/message'
export default {
methods:{
showMessage(){ messageSvc.alert( 'msg', 'title'); }
}
}
However, I'm encountering an issue where this.$alertify
is null.
My questions are:
- Is this the most efficient way to create a Vue service?
- How can I ensure that
this.$alertify
is available in my service?