Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
How to use dynamic component in vue-class-component

I use vue vue-class-component and it works fine:

import vuetify from '@/plugins/vuetify'
@Component({
    components: {
        vue2Dropzone
    },
    vuetify
})

But when I try to add new component for production only:

import store from '../store/Index'
let storeTmp = process.env.NODE_ENV === 'production' ? store : null
@Component({
    components: {
        vue2Dropzone
    },
    vuetify,
    storeTmp
})

I have the error:

Argument of type '{ components: { vue2Dropzone: any }; vuetify: Vuetify; storeTmp: Store<...> | null; }' is not assignable to parameter of type 'VueClass'.   Object literal may only specify known properties, but 'components' does not exist in type 'VueClass'. Did you mean to write 'component'?

How can I fix it?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Maybe

@Component({
    components: {
        vue2Dropzone
    },
    vuetify,
    store: storeTmp
})

?

There's no storeTmp property in the Vue instance, but there's store.

about 4 years ago · Juan Pablo Isaza Report

0

You can use computed in this. When you want to load a component based on some condition

In Template

<component v-bind:is="importComponent" :anyPropsYouWantToPas="props" />

In Computed

importComponent() {
    if (process.env.NODE_ENV === 'production) {
        return () => import(`@/components/app/componentpath`)
    }
},
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!