Boolean Casting
Props with boolean type mimic the behavior of native boolean attributes.
// This is equal to Enable = true
<Component Enable />
// This is equal to Enable false
<Component />
When we allow multiple props Boolean casting is also applied.
// True is casted
defineProps({
Enable: [Boolean, Number]
})
// True is casted
defineProps({
Enable: [Boolean, String]
})
// True is casted
defineProps({
Enable: [Number, Boolean]
})
// Absence of Enable will casted as empty string Enable=""
defineProps({
Enable: [String, Boolean]
})
Vue.js Props
Vue.js Props is an attribute to the configuration of the component. It is used to pass the data to the component to work dynamically. The props configuration defines the type of data it can receive from different components of Vue.
Table of Content
- Props Declaration
- Prop Passing Details
- One-Way Data Flow
- Prop Validation
- Boolean Casting