Checkbox Vue Component
Checkbox Vue component represents Checkbox component.
Checkbox Components
There are following components included:
**f7-checkbox**
Checkbox Properties
Prop | Type | Default | Description |
---|---|---|---|
<f7-checkbox> properties | |||
checked | boolean | Defines whether the checkbox input is checked or not | |
name | string number | Checkbox input name | |
value | string number boolean | Checkbox input value | |
disabled | boolean | Defines whether the checkbox input is disabled | |
readonly | boolean | Defines whether the checkbox input is readonly |
Checkbox Events
Event | Description |
---|---|
<f7-checkbox> events | |
change | Event will be triggered when checkbox state changed |
Checkboxes List
Checkboxes List is not a separate component, but just a particular case of using [<f7-list>]($9b027097947ca6d7.md)
, [<f7-list-item>]($acf7bf2b27ac6164.md)
.
<f7-list>
<!-- Additional "checkbox" prop to enable checkbox list item -->
<f7-list-item checkbox value="check_1" checked title="Checkbox 1"></f7-list-item>
<f7-list-item checkbox value="check_2" title="Checkbox 2"></f7-list-item>
</f7-list>
Checkbox v-model
v-model
is not supported on Checkbox vue component. Instead, just use the combination of checked
property and @change
event:
<template>
<!-- With boolean value -->
<f7-checkbox :checked="jobIsDone" @change="jobIsDone = $event.target.checked"></f7-checkbox>
<!-- With array value -->
<f7-checkbox
value="banana"
:checked="fruits.indexOf('banana') >= 0"
@change="checkFruits"
></f7-checkbox>
<f7-checkbox
value="orange"
:checked="fruits.indexOf('orange') >= 0"
@change="checkFruits"
></f7-checkbox>
<f7-checkbox
value="apple"
:checked="fruits.indexOf('apple') >= 0"
@change="checkFruits"
></f7-checkbox>
</template>
<script>
export default {
data() {
return {
jobIsDone: false,
fruits: [],
};
},
methods: {
checkFruits(event) {
const self = this;
const value = event.target.value;
if (event.target.checked) {
self.fruits.push(value);
} else {
self.fruits.splice(self.fruits.indexOf(value), 1);
}
},
},
};
</script>
Examples
<f7-block-title>Inline</f7-block-title>
<f7-block strong>
<p>Lorem <f7-checkbox name="checkbox-1"></f7-checkbox> ipsum dolor sit amet, consectetur adipisicing elit. Alias beatae illo nihil aut eius commodi sint eveniet aliquid eligendi <f7-checkbox name="checkbox-2" checked></f7-checkbox> ad delectus impedit tempore nemo, enim vel praesentium consequatur nulla mollitia!</p>
</f7-block>
<f7-block-title>Checkbox Group</f7-block-title>
<f7-list>
<f7-list-item checkbox title="Books" name="demo-checkbox" checked></f7-list-item>
<f7-list-item checkbox title="Movies" name="demo-checkbox"></f7-list-item>
<f7-list-item checkbox title="Food" name="demo-checkbox"></f7-list-item>
<f7-list-item checkbox title="Drinks" name="demo-checkbox"></f7-list-item>
</f7-list>
<f7-block-title>With Media Lists</f7-block-title>
<f7-list media-list>
<f7-list-item
checkbox
checked
name="demo-media-checkbox"
title="Facebook"
after="17:14"
subtitle="New messages from John Doe"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
></f7-list-item>
<f7-list-item
checkbox
name="demo-media-checkbox"
title="John Doe (via Twitter)"
after="17:11"
subtitle="John Doe (@_johndoe) mentioned you on Twitter!"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
></f7-list-item>
<f7-list-item
checkbox
name="demo-media-checkbox"
title="Facebook"
after="16:48"
subtitle="New messages from John Doe"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
></f7-list-item>
<f7-list-item
checkbox
name="demo-media-checkbox"
title="John Doe (via Twitter)"
after="15:32"
subtitle="John Doe (@_johndoe) mentioned you on Twitter!"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
></f7-list-item>
</f7-list>
当前内容版权归 Framework7 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Framework7 .