I’m new to using Vue. I’m trying to wrap my head around plugins. What i’m stuck on is using a component and its method that I add to my plugin:
Component: Rest.vue
...
export default {
name: 'rest',
data () {
return {
}
},
methods: {
gplFetch: function(query){
...
return ...;
}
}
}
...
Plugin: global-plugin
import Rest from ‘@/components/Rest.vue’
export default {
install(Vue, options) {
Vue.component(Rest.name, Rest)
Vue.mixin({
created() {
console.log('rest created');
}
})
Vue.prototype.$gplFetch = function(query){
return <Access Rest component>.gplFetch(query);
}
}
}
Using in main.js
import GlobalPlugin from '@/plugins/global-plugin.js'
Vue.use(GlobalPlugin);
What i’m stuck on is how to access gplFetch in the code above:
return <Access Rest component>.gplFetch(query);