Vue3 Boolean Casting #12174
Unanswered
StudentWvl
asked this question in
Help/Questions
Replies: 2 comments
-
type Booleanish = boolean | 'true' | 'false'; <input disabled="false" /> |
Beta Was this translation helpful? Give feedback.
0 replies
-
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.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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