# 模型 model

{
  "name": "",
  "area": "",
  "date": "",
  "switch": 0,
  "multi": [],
  "single": "",
  "description": ""
}
<template>
  <div class="demo-box">
    <form-builder ref="formBuilder" v-model="formModel" :form-data="formData">
      <template slot="actions">
        <el-form-item>
          <pre>{{ formModel }}</pre>
        </el-form-item>
      </template>
    </form-builder>
  </div>
</template>

<script>
export default {
  data() {
    return {
      formModel: {
        name: '',
        area: '',
        date: '',
        switch: 0,
        multi: [],
        single: '',
        description: ''
      },
      formData: {
        config: {
          labelWidth: '50px'
        },
        list: [{
          type: 'input',
          model: 'name',
          label: '名字',
          attrs: {
            placeholder: '请填写名字',
            clearable: true
          }
        }, {
          type: 'select',
          model: 'area',
          label: '区域',
          options: [{
            value: 'AREA1',
            label: '区域一'
          }, {
            value: 'AREA2',
            label: '区域二'
          }]
        }, {
          type: 'date-picker',
          model: 'date',
          label: '日期',
          attrs: {
            type: 'date',
            placeholder: '请选择日期'
          }
        }, {
          type: 'switch',
          model: 'switch',
          label: '开关'
        }, {
          type: 'checkbox-group',
          model: 'multi',
          label: '多选',
          options: [{
            label: '多选A'
          }, {
            label: '多选B'
          }, {
            label: '多选C'
          }]
        }, {
          type: 'radio-group',
          model: 'single',
          label: '单选',
          options: [{
            value: 'A',
            label: '单选A'
          }, {
            value: 'B',
            label: '单选B'
          }]
        }, {
          type: 'input',
          label: '描述',
          model: 'description',
          attrs: {
            type: 'textarea',
            rows: 3
          }
        }]
      }
    }
  }
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96