0

I've seen props being define like:

props: ['message', 'name', 'something']

and

props: {
    imperfectNumber: {
        type: Number,
        required: true
      }
 }

Whats the difference and how can I define some props that require no validation and others that do all in the same block?

6
  • 2
    You would do well to read through the documentation based on the last two questions. Both of them are covered. vuejs.org/v2/guide/components.html#Prop-Validation Commented Nov 15, 2017 at 16:27
  • I've read the docs, it does not answer either of my questions. Commented Nov 15, 2017 at 16:28
  • 2
    It absolutely does. Commented Nov 15, 2017 at 16:28
  • Where does it show how to use the string and object versions together? Commented Nov 15, 2017 at 16:29
  • Once you go down the object definition route, you have to do that with all the props. You can't mix them. Commented Nov 15, 2017 at 16:35

1 Answer 1

2

Once you go down the object definition route, you have to do that with all the props. You can't mix them.

You can find more information about the props here: https://v2.vuejs.org/v2/guide/components.html#Prop-Validation

Note:

Instead of defining the props as an array of strings, you can use an object with validation requirements

I've highlighted the part in the manual that explains. This indicates you can do one or the other.

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.