Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input v-checkbox checked by default

I Attempting to create a "v-checkbox" entry marked by default without using v-model directive.

In the official documentation for this Vuetify component I can't find the information on how to do this.

I tried to place this code but it doesn't work

<v-checkbox checked="true"></v-checkbox>
<v-checkbox  checked="checked"></v-checkbox>
<v-checkbox  checked></v-checkbox>
like image 233
Jorge Gatica Avatar asked Sep 17 '25 02:09

Jorge Gatica


1 Answers

One way to do this is by setting input-value="true", as described in the API docs.

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
})
<head>
  <link href="https://cdn.jsdelivr.net/npm/@mdi/[email protected]/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css" rel="stylesheet">
</head>

<div id="app">
  <v-app id="inspire">
    <v-checkbox label="Foo" input-value="1"></v-checkbox>
  </v-app>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.js"></script>
like image 199
jakub Avatar answered Sep 19 '25 20:09

jakub