Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
data-table
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2022-11-18 14:49:48 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f876b57e0b6b714d12d8e1bd3d239ed666160b4b
f876b57e
1 parent
4622c11d
✨ feat(单选按钮,多选按钮): 结构调整
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
14 deletions
src/components/CheckboxField/index.vue
src/components/RadioField/index.vue
src/components/CheckboxField/index.vue
View file @
f876b57
...
...
@@ -9,15 +9,27 @@
<div class="checkbox-field-page">
<div class="label">
{{ item.label }}
<span v-if="item.component_props.required" style="color: red;"> *</span>
<span v-if="item.component_props.max" style="color: gray;">(最多可选数: {{ item.component_props.max }})</span>
<span v-if="item.component_props.required" style="color: red"> *</span>
<span v-if="item.component_props.max" style="color: gray"
>(最多可选数: {{ 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>
...
...
src/components/RadioField/index.vue
View file @
f876b57
...
...
@@ -7,12 +7,21 @@
-->
<template>
<div class="radio-field-page">
<div class="label">{{ item.component_props.label }}<span v-if="item.component_props.required"> *</span></div>
<div class="label">
{{ item.component_props.label
}}<span v-if="item.component_props.required"> *</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>
...
...
Please
register
or
login
to post a comment