-1👍
You might want to read about Vue plugins.
Plugins usually add global-level functionality to Vue.
Extending Vue prototype is actually encouraged by the docs:
// 4. add an instance method
Vue.prototype.$myMethod = function (methodOptions) {
// something logic ...
}
For such a simple usecase it may be enough, but let’s say that you’d also want to have a loading indicator component triggered on API call. It may make sense to bundle and distribute them together using a Vue plugin. You can then install all the stuff plugin consists of with a single statement.
This is exactly what vue-router does.
Source:stackexchange.com