hookehuyr

✨ feat(单选按钮,多选按钮): 结构调整

......@@ -9,15 +9,27 @@
<div class="checkbox-field-page">
<div class="label">
{{ item.label }}
<span v-if="item.component_props.required" style="color: red;">&nbsp;*</span>
<span v-if="item.component_props.max" style="color: gray;">(最多可选数:&nbsp;{{ item.component_props.max }})</span>
<span v-if="item.component_props.required" style="color: red">&nbsp;*</span>
<span v-if="item.component_props.max" style="color: gray"
>(最多可选数:&nbsp;{{ item.component_props.max }})</span
>
</div>
<van-field :name=" item.key" :rules="item.rules" :border="false">
<van-field :name="item.key" :rules="item.rules" :border="false">
<template #input>
<van-checkbox-group v-model="item.value" :direction="item.component_props.direction"
:max="item.component_props.max">
<van-checkbox v-for="x in item.component_props.options" :key="index" :name="x.key" icon-size="1rem" shape="square"
style="margin-bottom: 0.25rem;">{{ x.value }}</van-checkbox>
<van-checkbox-group
v-model="item.value"
:direction="item.component_props.direction"
:max="item.component_props.max"
>
<van-checkbox
v-for="x in item.component_props.options"
:key="index"
:name="x"
icon-size="1rem"
shape="square"
style="margin-bottom: 0.25rem"
>{{ x }}</van-checkbox
>
</van-checkbox-group>
</template>
</van-field>
......@@ -26,8 +38,13 @@
<script setup>
const props = defineProps({
item: Object
})
item: Object,
});
onMounted(() => {
// 默认值为数组
props.item.value = [];
});
</script>
<style lang="less" scoped>
......
......@@ -7,12 +7,21 @@
-->
<template>
<div class="radio-field-page">
<div class="label">{{ item.component_props.label }}<span v-if="item.component_props.required">&nbsp;*</span></div>
<div class="label">
{{ item.component_props.label
}}<span v-if="item.component_props.required">&nbsp;*</span>
</div>
<van-field :name="item.key" :rules="item.rules">
<template #input>
<van-radio-group v-model="item.value" :direction="item.component_props.direction">
<van-radio v-for="x in item.component_props.options" :key="index" :name="x.key" icon-size="1rem"
style="margin-bottom: 0.25rem;">{{ x.value }}</van-radio>
<van-radio
v-for="x in item.component_props.options"
:key="index"
:name="x"
icon-size="1rem"
style="margin-bottom: 0.25rem"
>{{ x }}</van-radio
>
</van-radio-group>
</template>
</van-field>
......@@ -21,8 +30,8 @@
<script setup>
const props = defineProps({
item: Object
})
item: Object,
});
</script>
<style lang="less" scoped>
......