No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    [solved] Global custom component registration vs per-file registration

    Help
    2
    4
    1073
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rconstantine last edited by rconstantine

      I understand how to register a component on a per-file basis. I’ve got VueApexCharts working on a particular vue file. I also understand to some degree how to create plugins as I have for axios, casl, vuelidate, and vue-observe-visibility. However, none of those supplied VueJS components like VueApexCharts does. I was under the assumption that if I can globally register the component, then I won’t have to import and register on each vue file.

      My plugin file so far looks like this:

      import VueApexCharts from 'vue-apexcharts'
      
      export default ({ app, router, store, Vue }) => {
        Vue.use(VueApexCharts)
        console.log('components', app.components)
      }
      

      In place of the console log, I have tried to set the component of the app like this:

      app.components= {
          apexcharts: VueApexCharts,
        }
      

      but that doesn’t work. I’ve tried a few variations with no luck.

      I have read, and re-read the docs on plugins about 6 times, and also looked around here on the forum and read a couple dozen articles. Most related to components were of the per-file variety and the ones on global registration pointed to the docs or were for much older versions and didn’t work.

      I’m sure there is something small I’m not getting. Any pointers, here?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • R
        rconstantine last edited by

        Why do I always find the answer just after I post here?

        import VueApexCharts from 'vue-apexcharts'
        
        export default ({ app, router, store, Vue }) => {
          Vue.use(VueApexCharts)
          Vue.component('apexcharts', VueApexCharts)
        }
        
        1 Reply Last reply Reply Quote 0
        • s.molinari
          s.molinari last edited by

          It’s because writing things down get’s you thinking in different ways than if you were looking at a code editor. In other words, it get’s your mind less off the code and more about writing and explaining the answer to the question, “what the heck am I trying to do?”. 🤣 It happens to me all the time!

          Scott

          1 Reply Last reply Reply Quote 2
          • s.molinari
            s.molinari last edited by s.molinari

            Also, I’ve never registered a component globally in Quasar, but is “Vue.use” needed for that?

            Edit: Nevermind. I see it is a Vue plugin. Glad you got it working!

            Edit2: And wow. Apex Charts looks pretty damn good. me bookmarking for future reference

            Edit3: Looking at Apex Charts, this could be another example of user shared components, where different types of charts are made as chart components for Quasar. I’m thinking of those dynamic examples shown in the demos where a button is needed. 😎

            Scott

            1 Reply Last reply Reply Quote 0
            • First post
              Last post