@form-create/vant
Version:
VantUI版本低代码表单|FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。内置20种常用表单组件和自定义组件,再复杂的表单都可以轻松搞定。
39 lines (35 loc) • 1.18 kB
JSX
import {defineComponent, toRef} from 'vue';
const NAME = 'fcCheckbox';
export default defineComponent({
name: NAME,
inheritAttrs: false,
props: {
modelValue: Array,
options: Array,
},
emits: ['update:modelValue', 'change'],
setup(props, _) {
const modelValue = toRef(props, 'modelValue', []);
const options = toRef(props, 'options');
return {
options,
modelValue,
onInput(val) {
_.emit('update:modelValue', val);
_.emit('change', val);
},
}
},
render() {
return <van-checkbox-group direction="horizontal" {...this.$attrs} modelValue={Array.isArray(this.modelValue) ? this.modelValue : []}
onUpdate:modelValue={this.onInput}>
{(this.options || []).map(opt => {
const tmp = {...opt};
const {text, value} = opt;
delete tmp.text;
delete tmp.value;
return <van-checkbox name={value} shape="square" {...tmp}>{text || opt.label || value}</van-checkbox>
})}
</van-checkbox-group>
}
});