0

I'm currently exploring Vue JS Plugin and Im trying to create my own plugin, but after I build console returns "GlobalDataMethods is not defined". What am I missing here?

GlobalDataMethods.install = function(Vue, options) {
    Vue.getAPIData = function(paramObj) {

    }

    Vue.getFormData = function(formId) {

    }
}

Vue.use(GlobalDataMethods);

1 Answer 1

3

GlobalDataMethods needs to be something. You're adding an install property to GlobalDataMethods, but you never define GlobalDataMethods.

const GlobalDataMethods = {}
GlobalDataMethods.install = ...
Vue.use(GlobalDataMethods)

Consider the VueRouter plugin. The router definition is a class. The install method is added to that class.

Sign up to request clarification or add additional context in comments.

1 Comment

so plugin needs to be defined first, thanks @BertEvans

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.