Skip to content

Commit 3119f1d

Browse files
NataliaTepluhinaphanan
authored andcommitted
Added options for object-based props definition in API (#2028)
* feat: add API entry on props options - fixed a link to props section * fix: moved a link and added read-more types link * Update src/v2/api/index.md Co-Authored-By: NataliaTepluhina <NataliaTepluhina@users.noreply.github.com> * Update src/v2/api/index.md Co-Authored-By: NataliaTepluhina <NataliaTepluhina@users.noreply.github.com> * Update src/v2/api/index.md Co-Authored-By: NataliaTepluhina <NataliaTepluhina@users.noreply.github.com>
1 parent 5a96862 commit 3119f1d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/v2/api/index.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,15 @@ type: api
509509

510510
A list/hash of attributes that are exposed to accept data from the parent component. It has an Array-based simple syntax and an alternative Object-based syntax that allows advanced configurations such as type checking, custom validation and default values.
511511

512+
With Object-based syntax, you can use following options:
513+
- **type:** can be one of the following native constructors: `String`, `Number`, `Boolean`, `Array`, `Object`, `Date`, `Function`, `Symbol`, any custom constructor function or an array of those. Will check if a prop has a given type, and will throw a warning if it doesn't. [More information](../guide/components-props.html#Prop-Types) on prop types.
514+
- **default:** `any`
515+
Specifies a default value for the prop. If the prop is not passed, this value will be used instead. Object or array defaults must be returned from a factory function.
516+
- **required:** `Boolean`
517+
Defines if the prop is required. In a non-production environment, a console warning will be thrown if this value is truthy and the prop is not passed.
518+
- **validator:** `Function`
519+
Custom validator function that takes the prop value as the sole argument. In a non-production environment, a console warning will be thrown if this function returns a falsy value (i.e. the validation fails). You can read more about prop validation [here](../guide/components-props.html#Prop-Validation).
520+
512521
- **Example:**
513522

514523
``` js
@@ -535,7 +544,7 @@ type: api
535544
})
536545
```
537546

538-
- **See also:** [Props](../guide/components.html#Props)
547+
- **See also:** [Props](../guide/components-props.html)
539548

540549
### propsData
541550

0 commit comments

Comments
 (0)