0

I want to pass boolean value on input, like

  v-bind:value="false"

but it doesn't work, on true it work but it doesn't work on false, what could be the cause ?

1
  • What is not working ? It should work. Check this fiddle : jsfiddle.net/0w7q9d6o Commented Jun 19, 2022 at 11:36

1 Answer 1

1

Depending on your use case, you can either use "" (empty string) instead of false, or reorganize your component that uses this property. Quoting the docs:

Boolean attributes are attributes that can indicate true / false values by its presence on an element. For example, disabled is one of the most commonly used boolean attributes.

v-bind works a bit differently in this case:

<button :disabled="isButtonDisabled">Button</button>

The disabled attribute will be included if isButtonDisabled has a truthy value. It will also be included if the value is an empty string, maintaining consistency with <button disabled="">.

For other falsy values the attribute will be omitted.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.