Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
Vue3 variable is assigned but never used when trying to pass props to child

Vue newbie here. I'm trying to pass some props from parent to child, but I get the "variable is assigned a value but never used".

Parent:

<template>
  <TextBox :heading="heading1" :body="body1" />
</template>

<script>
import TextBox from "./components/TextBox.vue";
import { ref } from "vue";

export default {
  name: "App",
  components: {
    TextBox,
  },

  setup() {
    const heading1 = ref("Primo titolo");
    const body1 = ref("Primo corpo del testo");
  },
};
</script>

Child:

<template>
<h1>{{ heading }}</h1>
<p>{{ body }}</p>
</template>

<script>
export default {
  name: 'TextBox',
  props: {
    heading: String,
    body: String,
  }
}
</script>

What am I missing? Thank you!

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

0

If you are using composition API setup function you need to return, or you can use data function from options API :

const { ref } = Vue
const app = Vue.createApp({
  setup() {
    const heading1 = ref("Primo titolo");
    const body1 = ref("Primo corpo del testo");
    return { heading1, body1 }
  },
})
app.component('TextBox', {
  template: `
    <h1>{{ heading }}</h1>
    <p>{{ body }}</p>
  `,
  props: {
    heading: String,
    body: String,
  }
})
app.mount('#demo')
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<div id="demo">
  <text-box :heading="heading1" :body="body1" />
</div>

about 4 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda