Vue3 Boolean Casting #12174
Replies: 2 comments
-
type Booleanish = boolean | 'true' | 'false'; <input disabled="false" /> |
Beta Was this translation helpful? Give feedback.
-
I'm not 100% sure what you mean, but this code: <MyComponent disabled="false"> will never resolve the prop value as if ("false") {
// this will run, because it's a string, not the boolean false
} If you have specified a type for your prop, meaning it's defined like this: defineProps({
disabled: Boolean
}); then you should see a warning from Vue in the console:
which should give a hint on what's going on. <MyComponent :disabled="false"> (note the colon before You can read the guide on Props for more info. |
Beta Was this translation helpful? Give feedback.
-
If there is a component < MyComponent > that contains a Boolean prop disabled.
Then < MyComponent disabled="false" > will bind attr in this way and resolve to true in the component?
Is this normal?
Beta Was this translation helpful? Give feedback.
All reactions