vue+element創(chuàng)建動態(tài)的form表單及動態(tài)生成表格的行和列
動態(tài)創(chuàng)建form表單,網(wǎng)上有插件 (form-create) 不過我不知道它怎么用,沒有使用成功,如果你使用成功了,歡迎下方留言.
最后我使用了笨方法,針對各個表單寫好通用的組件,然后根據(jù)type用v-if來渲染對應(yīng)的表單,數(shù)據(jù),事件什么的都可以動態(tài)的傳進(jìn)去,比較好用
<el-form size="mini" class="lj-form lj-form-s1">
<div v-for="(item,i) in table.customerList" :key="i">
<!-- 0單行文本 -->
<el-form-item
:label="item.field_title + ': '"
v-if="item.field_type == '0' && item.is_show == '1'"
>
<el-input v-model="item.value" :placeholder="item.placeholder"></el-input>
</el-form-item>
<!-- 3下拉菜單 -->
<el-form-item
:label="item.field_title + ': '"
v-if="item.field_type == '3' && item.is_show == '1'"
>
<el-select v-model="item.value" :placeholder="item.placeholder">
<span v-for="(item1,i) in item.field_value" :key="i">
<el-option :label="item1" :value="item1"></el-option>
</span>
</el-select>
</el-form-item>
</div>
</el-form>
動態(tài)生成表格的行和列,主要是要求后端返回的數(shù)據(jù)格式,根據(jù)數(shù)據(jù)來動態(tài)渲染
注意點(diǎn):這里兩個數(shù)組 : 表格字段數(shù)據(jù): titleData: [], 表格詳細(xì)數(shù)據(jù): tables: [], 數(shù)據(jù)通過字段來查找/渲染成表格的
<template>
<div class="boxShadow">
<div style="margin-top: 20px">
<el-table
:data="tables"
ref="multipleTable"
tooltip-effect="dark"
style="width: 100%"
@selection-change='selectArInfo'>
<el-table-column type="selection" width="45px"></el-table-column>
<el-table-column label="序號" width="62px" type="index">
</el-table-column>
<template v-for='(col) in titleData'>
<el-table-column
sortable
:show-overflow-tooltip="true"
:prop="col.dataItem"
:label="col.dataName"
:key="col.dataItem"
width="124px">
</el-table-column>
</template>
<el-table-column label="操作" width="80" align="center">
<template slot-scope="scope">
<el-button size="mini" class="del-com" @click="delTabColOne()" ><i class="iconfont icon-shanchu"></i></el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
</template>
data () {
return {
tables: [{
xiaoxue: '福蘭',
chuzhong: '加芳',
gaozhong: '蒲廟',
daxue: '西安',
yanjiusheng: '西安',
shangban: '北京'
}, {
xiaoxue: '南坊',
chuzhong: '禮泉',
gaozhong: '禮泉',
daxue: '西安',
yanjiusheng: '西安',
shangban: '南坊'
}, ],
titleData: [{
dataItem: 'xiaoxue',
dataName: '小學(xué)'
}, {
dataItem: 'chuzhong',
dataName: '初中'
}, {
dataItem: 'gaozhong',
dataName: '高中'
}, {
dataItem: 'daxue',
dataName: '大學(xué)'
}, {
dataItem: 'yanjiusheng',
dataName: '研究生'
}, {
dataItem: 'shangban',
dataName: '上班'
}]
}
總結(jié)
以上所述是小編給大家介紹的vue+element創(chuàng)建動態(tài)的form表單及動態(tài)生成表格的行和列,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復(fù)大家的!
- vue+elementUI動態(tài)增加表單項并添加驗證的代碼詳解
- vue+element實現(xiàn)動態(tài)加載表單
- Vue+Element實現(xiàn)動態(tài)生成新表單并添加驗證功能
- 詳解Vue+Element的動態(tài)表單,動態(tài)表格(后端發(fā)送配置,前端動態(tài)生成)
- 基于Vue+elementUI實現(xiàn)動態(tài)表單的校驗功能(根據(jù)條件動態(tài)切換校驗格式)
- vue element動態(tài)渲染、移除表單并添加驗證的實現(xiàn)
- Vue+ElementUI實現(xiàn)表單動態(tài)渲染、可視化配置的方法
- Element+Vue實現(xiàn)動態(tài)表單多個下拉框組件功能
相關(guān)文章
vue實現(xiàn)多個echarts根據(jù)屏幕大小變化而變化實例
這篇文章主要介紹了vue實現(xiàn)多個echarts根據(jù)屏幕大小變化而變化實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-07-07
在vue.js渲染完界面之后如何再調(diào)用函數(shù)
這篇文章主要介紹了在vue.js渲染完界面之后如何再調(diào)用函數(shù)的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-07-07

