import { ref, onBeforeUpdate } from 'vue' import { CheckboxGroup as VanCheckboxGroup, Checkbox as VanCheckbox, Cell as VanCell } from 'vant' import { useFormInput, useOptions } from '../../../hooks/form-input' import { formInputProps, fromInputEmits } from '../../form-input-props' export default { props: formInputProps, emits: [...fromInputEmits], setup (props, context) { const { updateStream, width } = useFormInput(props, context) const { optionProps, options, proxyOptionsValue } = useOptions(props, true, updateStream) const checkboxRefs = ref([]) const checkRefFn = (el, index) => { checkboxRefs.value[index] = el } const cellToggle = (index) => { checkboxRefs.value[index].toggle() } onBeforeUpdate(() => { checkboxRefs.value = [] }) const checkboxItem = (option, index) => checkRefFn(el, index)} onclick={e => e.stopPropagation()} /> // 优化操作-cell增加点击事件 const cellItem = (option, index) => checkboxItem(option, index) }} title={option[optionProps.value.label] ?? option} onclick={() => cellToggle(index)} clickable /> const checkboxItems = () => options.value.map(cellItem) return () => {checkboxItems()} } }