Create form form dynamically. There is a form create on the Internet, but I don't know how to use it. It's not successful. If you use it successfully, please leave a message below
Finally, I used stupid methods to write general components for each form, and then use v-if to render the corresponding form, data, events and so on according to the type, which can be transferred in dynamically, which is easier to use
1 <el-form size="mini" class="lj-form lj-form-s1">
2 <div v-for="(item,i) in table.customerList" :key="i">
3 <!-- 0 Single line text -->
4 <el-form-item
5 :label="item.field_title + ': '"
6 v-if="item.field_type == '0' && item.is_show == '1'"
7 >
8 <el-input v-model="item.value" :placeholder="item.placeholder"></el-input>
9 </el-form-item>
10 <!-- 3 drop-down menu -->
11 <el-form-item
12 :label="item.field_title + ': '"
13 v-if="item.field_type == '3' && item.is_show == '1'"
14 >
15 <el-select v-model="item.value" :placeholder="item.placeholder">
16 <span v-for="(item1,i) in item.field_value" :key="i">
17 <el-option :label="item1" :value="item1"></el-option>
18 </span>
19 </el-select>
20 </el-form-item>
21 </div>
22 </el-form>
Dynamically generate the rows and columns of the table, mainly requiring the data format returned by the back end, and dynamically render according to the data
Note: here are two arrays: table field data: titleData: [], table detail data: tables: [], which are used to find / render the data into a table
1 <template>
2 <div class="boxShadow">
3 <div style="margin-top: 20px">
4
5 <el-table
6 :data="tables"
7 ref="multipleTable"
8 tooltip-effect="dark"
9 style="width: 100%"
10 @selection-change='selectArInfo'>
11 <el-table-column type="selection" width="45px"></el-table-column>
12 <el-table-column label="Serial number" width="62px" type="index">
13 </el-table-column>
14 <template v-for='(col) in titleData'>
15 <el-table-column
16 sortable
17 :show-overflow-tooltip="true"
18 :prop="col.dataItem"
19 :label="col.dataName"
20 :key="col.dataItem"
21 width="124px">
22 </el-table-column>
23 </template>
24 <el-table-column label="operation" width="80" align="center">
25 <template slot-scope="scope">
26 <el-button size="mini" class="del-com" @click="delTabColOne()" ><i class="iconfont icon-shanchu"></i></el-button>
27 </template>
28 </el-table-column>
29 </el-table>
30
31
32 </div>
33 </div>
34
35 </template>
1 data () {
2 return {
3 tables: [{
4 xiaoxue: 'Forlan',
5 chuzhong: 'Add aromatic',
6 gaozhong: 'Pu Temple',
7 daxue: 'Xi'an',
8 yanjiusheng: 'Xi'an',
9 shangban: 'Beijing'
10 }, {
11 xiaoxue: 'Nanfang',
12 chuzhong: 'source of sweet water',
13 gaozhong: 'source of sweet water',
14 daxue: 'Xi'an',
15 yanjiusheng: 'Xi'an',
16 shangban: 'Nanfang'
17 }, ],
18 titleData: [{
19 dataItem: 'xiaoxue',
20 dataName: 'Primary school'
21 }, {
22 dataItem: 'chuzhong',
23 dataName: 'Junior middle school'
24 }, {
25 dataItem: 'gaozhong',
26 dataName: 'high school'
27 }, {
28 dataItem: 'daxue',
29 dataName: 'University'
30 }, {
31 dataItem: 'yanjiusheng',
32 dataName: 'Graduate student'
33 }, {
34 dataItem: 'shangban',
35 dataName: 'go to work'
36 }]
37 }