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

289
Visualizações
Vue 3 - can i avoid using .value everywhere?

I'm quite new to Vue 3 and i'm struggling a lot to understand some concepts of the composition API. I'm trying to port a library i'm using from vue 2 to vue 3, and in a parent element a reactive property called layout is passed to children components.

So in the parent component i'm returning layout to the children like this:

setup(props){
    const layout = ref({'width': 10, ... })
    return {
        layout,
        ...
    }
}

The problem is that, in order to access width or any other reactive value in layout from any children component i need to use the syntax layout.value.width. This is quite a problem because through the whole project layout is referenced with layout.width, this means that i need to add a .value to every reference to layout and do the same for all the other reactive variables i'm passing to my children components. Is there any way to avoid this or am i just not getting some important concepts from the composition api?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

There are at least two ways:

  1. Yes. You can work without the .value. You have to use the vue experimental version

or

  1. You can create a reactive variable, like:
<script setup>
import { reactive } from 'vue'

const layout = reactive({'width': 10, ... })
</script>
about 4 years ago · Santiago Trujillo 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