输入 v-checkbox 默认选中

Jor*_*ica 3 vue.js vue-component vuetify.js

我尝试创建默认标记的“v-checkbox”条目,而不使用 v-model 指令

在这个 Vuetify 组件的官方文档中,我找不到有关如何执行此操作的信息。

我尝试放置此代码,但它不起作用

<v-checkbox checked="true"></v-checkbox>
<v-checkbox  checked="checked"></v-checkbox>
<v-checkbox  checked></v-checkbox>
Run Code Online (Sandbox Code Playgroud)

Jak*_*kub 8

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

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
})
Run Code Online (Sandbox Code Playgroud)
<head>
  <link href="https://cdn.jsdelivr.net/npm/@mdi/font@4.x/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/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/vue@2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>
Run Code Online (Sandbox Code Playgroud)