0
How do I make a v-if "If the v-checkbox is checked" ? tried v-if(model-name == true) did not work
0
How do I make a v-if "If the v-checkbox is checked" ? tried v-if(model-name == true) did not work
0
A simple example, we have the checkbox associated with an object called checked
<input type="checkbox" id="checkbox" v-model="checked">
<label for="checkbox">Você é maior de 18 anos?</label>
<h1 v-if="checked"> Você pode tirar a habilitação! </h1>
<h1 v-if="!checked"> Você não pode tirar a habilitação! </h1>
and at the date:
data() {
return {
checked: false,
}
}
since the checked value is initially set to false, the checkbox will be unchecked and the text that will appear is "You cannot enable" because v-if is '!checked', the ! imposes that if checked is the inverse of true, or false, the condition is true and will perform such an action, which in this case is to display this string.
Browser other questions tagged vue.js
You are not signed in. Login or sign up in order to post.
v-if="modelName"
– JrD