Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda