0
votes

I'm trying to use vuetify components inside my custom vue plugin that I have created, but it seems that my plugin rendering before the app "knows" that vuetify exists.

i have tried to use Vue.use(Vuetify) inside my plugin but it didn't works and basically, it dosnt make sense to use it in my plugin since i want that the plugin user(developer) will use vuetify as a global dependency in his app so it can seep down to my plugin

this is my vue html template of the plugin:

<v-content>
      <v-container fluid fill-height>
        <v-layout justify-center>
        <div v-if="videoLoading">
          <v-progress-circular v-if="useVuetifyLoader"
            :size="size"
            :width="width"
            :rotate="rotate" 
            :value="videoLoadingProgress*1.5"
            :color="color"
          >
            Downloading...
            {{ `${loadedInMB}/${totalInMb}Mb` }}
          </v-progress-circular>
          <div v-else>
              Downloading...
              {{ `${loadedInMB}/${totalInMb}Mb` }}
          </div>
        </div>
        <div v-else>
          <div>
            <div>foo</div>
          </div>
        </div>
      </v-layout>
    </v-container>
  </v-content>

and this is my plugin :

import MyPlugin from '../lib/MyPlugin.vue';
import Vuetify from 'vuetify'


const install = function (Vue, config) {

Vue.component("my-plugin", MyPlugin)

}




export { install }

*and i tried also :*



 import MyPlugin from '../lib/MyPlugin.vue';
    import Vuetify from 'vuetify'


    const install = function (Vue, config) {
    Vue.use(Vuetify)// <-- did not work
    Vue.component("my-plugin", MyPlugin)

    }




    export { install }

and when I implementing my plugin in other app i'm getting these errors:

Unknown custom element: <v-content> - did you register the component correctly? For recursive components, make sure to provide the "name" option

 Unknown custom element: <v-container> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

Unknown custom element: <v-layout> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

Unknown custom element: <v-progress-circular> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
2

2 Answers

0
votes

How about setting up your plugin like this and include the custom components inside:

export default {
  install (Vue, options) {
     Vue.anyMethodYouLike = (value) => value

     Vue.component('v-content', Component);
     // Add `Vue.mixin()` to inject options to all components.
     Vue.mixin({
         // Add component lifecycle hooks and/or properties.
         created() {
         }
     });
     // We can also add Vue instance methods by attaching them to Vue.prototype.
     Vue.property.$myProperty = 'This is a Vue instance property.'
  }
}

Then use within your app like:

import myPlugin from './plugin.js' // the file with the code above

Vue.use(myPlugin, {
  someProp: 'blahdy blah'  //options to pass
})
0
votes

ok, so I figure it out. all I had to do is to pass Vuetify as a param in the options object and then I could use it in my plugin file with Vue.use(my_vuetify_param)