mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
docs(checkbox): fix cell demo #7039
This commit is contained in:
parent
8d3d944594
commit
2c55fed8b7
@ -96,7 +96,7 @@
|
||||
@click="toggle(index)"
|
||||
>
|
||||
<template #right-icon>
|
||||
<van-checkbox ref="checkboxes" :name="item" />
|
||||
<van-checkbox :ref="setRefs(index)" :name="item" />
|
||||
</template>
|
||||
</van-cell>
|
||||
</van-cell-group>
|
||||
@ -106,6 +106,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from 'vue';
|
||||
import { useRefs } from '../../composition/use-refs';
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
@ -140,6 +143,31 @@ export default {
|
||||
},
|
||||
},
|
||||
|
||||
setup() {
|
||||
const group = ref();
|
||||
const [refs, setRefs] = useRefs();
|
||||
|
||||
const toggle = (index) => {
|
||||
refs.value[index].toggle();
|
||||
};
|
||||
|
||||
const checkAll = () => {
|
||||
group.value.toggleAll(true);
|
||||
};
|
||||
|
||||
const toggleAll = () => {
|
||||
group.value.toggleAll();
|
||||
};
|
||||
|
||||
return {
|
||||
group,
|
||||
toggle,
|
||||
setRefs,
|
||||
checkAll,
|
||||
toggleAll,
|
||||
};
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
checkbox1: true,
|
||||
@ -158,21 +186,6 @@ export default {
|
||||
inactiveIcon: 'https://img.yzcdn.cn/vant/user-inactive.png',
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
toggle(index) {
|
||||
// TODO ref in for
|
||||
this.$refs.checkboxes[index].toggle();
|
||||
},
|
||||
|
||||
checkAll() {
|
||||
this.$refs.group.toggleAll(true);
|
||||
},
|
||||
|
||||
toggleAll() {
|
||||
this.$refs.group.toggleAll();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user