2

I'm trying to pass props value in vue component to object as index like code below.

export default defineComponent({
  props:{
    pollId:{type: String}
  },
  data(){
    return{
      poll: polls[this.pollId]
    }
  }
})

But when I do this, I got error like these: error

the compiler keeps assuming that my props are undefined even I've specified it above.

is there a way to fix this? without sacrificing

1 Answer 1

1

It's actually as simple as adding required property in props

export default defineComponent({
  props:{
    pollId:{required:true,type: String}
  },
  data(){
    return{
      poll: polls[this.pollId]
    }
  }
})
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.