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

214
Vistas
Why do these Vue props fail outside the main component?

I am working on a Vue 3 app. I have run into a problem working with a <Navbar /> component and one of its sub-components.

In App.vue:

<template>
  <Navbar />
  <Content title="Home" />
  <Footer />
</template>

<script>
import Navbar from './components/Navbar.vue'
import Content from './components/Content.vue'
import Footer from './components/Footer.vue'

export default {
  name: 'App',
  components: {
    Navbar,
    Content,
    Footer
  }
}
</script>

Within the Content.vue component, I can display the title this way:

<h1>{{ title }}</h1>

<script>
export default {
  name: 'Content',
  props: {
    title: String
  }
}
</script>

But displaying buttons with their labels by the same pattern as above does not work:

// Button.vue component

<template>
  <button class="btn btn-sm btn-generate">
    {{ label }}
  </button>
</template>

<script>
export default {
  name: 'Button',
  props: {
    label: String
  }
}
</script>


// Navbar.vue component

<template>
    <div class="navbar">
        <Button label="Button 1" />
        <Button label="Button 2" />
    </div>
</template>

<script>
import Button from './Button'
export default {
  name: 'Navbar',
  components: {
    Button
  }
}
</script>

The problem

As a result of the code above, inside <div class="navbar"> there is only one button with no label, instead of 2 buttons labeled "Button 1" and "Button 2".

Where is my mistake?

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

0

I think that naming your component just as the already existing HTML element is not a good idea. Try changing it to MyButton and use <my-button>... in the navbar component (you still want to use <button> in MyButton, as you want to build upon it).

Most probably browser still picks just a default button instead of yours.

The first essential rule mentioned in Vue docs is Use multi-word component names.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You need to bind them so :label="button 1"

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