admin管理员组文章数量:1404927
I am using the Vuetify ponent v-checkbox
.
I want to specify specific values for the true/false states of the checkbox.
Looking at the documentation it looks like I can do this using the true-value
& false-value
props.
<v-checkbox
v-else-if="input.type == 'checkbox'"
false-value="0"
true-value="1"
input-value="input.val"
:error-messages="form.errors[field]"
>
<template #label>@{{ input.hint }}</template>
</v-checkbox>
However using the example above does not submit a value of 1
when the checkbox is checked. The checkbox submits 0
regardless of whether the checkbox is checked or not.
What do I need to do to properly set the true-value
to 1
?
I am using the Vuetify ponent v-checkbox
.
I want to specify specific values for the true/false states of the checkbox.
Looking at the documentation it looks like I can do this using the true-value
& false-value
props.
<v-checkbox
v-else-if="input.type == 'checkbox'"
false-value="0"
true-value="1"
input-value="input.val"
:error-messages="form.errors[field]"
>
<template #label>@{{ input.hint }}</template>
</v-checkbox>
However using the example above does not submit a value of 1
when the checkbox is checked. The checkbox submits 0
regardless of whether the checkbox is checked or not.
What do I need to do to properly set the true-value
to 1
?
-
Vuetify documentation says the
input-value
prop is supposed to beThe v-model bound value
– VerySeriousSoftwareEndeavours Commented Jul 4, 2019 at 22:14 -
1
The problem is that you used
input-value
instead of:input-value
(notice:
).input-value
property exists. – Traxo Commented Jul 5, 2019 at 6:49
1 Answer
Reset to default 0You should use v-model
directive instead of input-value
prop like :
<v-checkbox
v-else-if="input.type == 'checkbox'"
false-value="0"
true-value="1"
v-model="input.val"
:error-messages="form.errors[field]"
>
<template #label>@{{ input.hint }}</template>
</v-checkbox>
check this code example
本文标签: javascriptSpecifying truefalse values for a Vuetify vcheckboxStack Overflow
版权声明:本文标题:javascript - Specifying truefalse values for a Vuetify v-checkbox - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744874413a2629828.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论