• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

161
Vistas
vue3 It seems that the setup function returns before the onMount function
createApp({
    setup() {
        let price = 0
    
        onMounted() {
            // axios
            price = axios.response
        }
        return { price }
    }
}).mount('#app')

HTML

<h6 id="app" class="mb-0">{{price}}</h6>

The current situation is that a value of 0 is continuously output. Looking at the order, it seems that the setup function returns before the onMounted function and has already done the rendering.

What should I do?

about 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You should use price = ref(0) for reactivity.

https://vuejs.org/api/composition-api-setup.html#basic-usage

about 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda