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

206
Vistas
Why i am getting a warning about of string type if i am passing a string?

i want to pass a String to my child component like this, but previously i want to print it

this is my parent component

    {{left.leftA}} // here show me 8
        <CustomCard
          :left="left.leftA"
export default {
    name: 'Parent',
    data() {},
    setup() {
    onMounted(async () => {
        const answer = await getData(name)
        left.value = answer.response //{leftA:'A', leftB:'B'...}
      })

and in my child component i have this declaration

export default {
    name: 'CustomCard',
    props: {
    left: {
        type: String,
        required: true,
      },

i am getting this warning:

  [Vue warn]: Invalid prop: type check failed for prop "left". Expected String with 
value "undefined", got Undefined 

Does it have something to do with how I am loading the data? is it ok to use onMounted?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This is happening because the initial value for value is null. So, on initial render it throws the warning, but upon another render it has the correct prop type (a string) and renders correctly.

You have 3 options. Allow '' as an option on the prop or don’t render the component until you have the correct data or make use of computed Property.

Option-1

{{left.leftA}} // here show me 8
    <CustomCard
      :left="left.leftA ? left.leftA : ''"

Option-2

{{left.leftA}} // here show me 8
    <CustomCard v-if="loaded"
      :left="left.leftA"

and in onMounted(}

  onMounted(async () => {
        const answer = await getData(name)
        left.value = answer.response //{leftA:'A', leftB:'B'...}
        // Set the loaded flag as true here. Also make sure its set as false inside the setup()
      })

Option-3

{{left.leftA}} // here show me 8
    <CustomCard
      :left="sendVal"



In computed....

computed: {
  sendVal() {
   if(left && left.left1) return left.left1;
   return '';
  }
}

over 4 years ago · Santiago Trujillo 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