element可編輯表格驗(yàn)證問題解決
前提:表格里設(shè)置可編輯表單。
注意事項(xiàng):
1.校驗(yàn)需要觸發(fā)表單,而表格需要時(shí)數(shù)組。因此表單綁定的是一個(gè)對象,表格中綁定的是該對象中的數(shù)組。
2.prop動(dòng)態(tài)綁定。
3.必要的情況下可以添加key的。(:key=‘scope.row.key’)
<el-form :model="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm">
? ? ? ? ? ? <el-table ?:data="ruleForm.tableList" style="width: 100%">
? ? ? ? ? ? ? ? <el-table-column prop="name" align="center">
? ? ? ? ? ? ? ? ? ? <template slot-scope="scope">
? ? ? ? ? ? ? ? ? ? ? ? <el-form-item label="活動(dòng)名稱" :prop="'tableList.'+scope.$index+'.name'" :rules='rules.name'>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <el-input v-model="scope.row.name"></el-input>
? ? ? ? ? ? ? ? ? ? ? ? </el-form-item>
? ? ? ? ? ? ? ? ? ? </template>
? ? ? ? ? ? ? ? </el-table-column>
? ? ? ? ? ? ? ? <el-table-column align="center">
? ? ? ? ? ? ? ? ? ? <template>
? ? ? ? ? ? ? ? ? ? ? ? ?<el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
? ? ? ? ? ? ? ? ? ? ? ? ?<el-button @click="resetForm('ruleForm')">重置</el-button>
? ? ? ? ? ? ? ? ? ? </template>
? ? ? ? ? ? ? ? </el-table-column>
? ? ? ? ? ? </el-table>
? ? ? </el-form>
export default {
? ? data() {
? ? ? return {
? ? ? ? ruleForm: {
? ? ? ? ? tableList: [],
? ? ? ? },
? ? ? ? rules: {
? ? ? ? ? name: [
? ? ? ? ? ? { required: true, message: '請輸入活動(dòng)名稱', trigger: 'blur' },
? ? ? ? ? ? { min: 3, max: 5, message: '長度在 3 到 5 個(gè)字符', trigger: 'blur' }
? ? ? ? ? ],
? ? ? ? }
? ? ? };
? ? },
? ? methods: {
? ? ? submitForm(formName) {
? ? ? ? this.$refs[formName].validate((valid) => {
? ? ? ? ? if (valid) {
? ? ? ? ? ? alert('submit!');
? ? ? ? ? } else {
? ? ? ? ? ? console.log('error submit!!');
? ? ? ? ? ? return false;
? ? ? ? ? }
? ? ? ? });
? ? ? },
? ? ? resetForm(formName) {
? ? ? ? this.$refs[formName].resetFields();
? ? ? }
? ? }
}到此這篇關(guān)于element可編輯表格驗(yàn)證問題解決的文章就介紹到這了,更多相關(guān)element可編輯表格驗(yàn)證內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- VUE2.0+ElementUI2.0表格el-table循環(huán)動(dòng)態(tài)列渲染的寫法詳解
- vue+element-ui實(shí)現(xiàn)表格編輯的三種實(shí)現(xiàn)方式
- vue.js+Element實(shí)現(xiàn)表格里的增刪改查
- vue+Element中table表格實(shí)現(xiàn)可編輯(select下拉框)
- elementUI中Table表格問題的解決方法
- element-ui 表格數(shù)據(jù)時(shí)間格式化的方法
- 利用vue + element實(shí)現(xiàn)表格分頁和前端搜索的方法
- 優(yōu)雅的將ElementUI表格變身成樹形表格的方法步驟
- element-ui 表格實(shí)現(xiàn)單元格可編輯的示例
- 詳解vue2.0的Element UI的表格table列時(shí)間戳格式化
相關(guān)文章
element中el-table表頭通過header-row-style設(shè)置樣式
有些時(shí)候需要給element-ui表頭設(shè)置不同樣式,本文主要介紹了element中el-table表頭通過header-row-style設(shè)置樣式,具有一定的參考價(jià)值,感興趣的可以了解一下2024-01-01
詳解在Vue.js編寫更好的v-for循環(huán)的6種技巧
這篇文章主要介紹了詳解在Vue.js編寫更好的v-for循環(huán)的6種技巧,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-04-04
vue項(xiàng)目上傳Github預(yù)覽的實(shí)現(xiàn)示例
這篇文章主要介紹了vue項(xiàng)目上傳Github預(yù)覽的實(shí)現(xiàn)示例,在完成Vue項(xiàng)目以后,在上傳到github并實(shí)現(xiàn)預(yù)覽2018-11-11
vue3插槽:el-table表頭插入tooltip及更換表格背景色方式
這篇文章主要介紹了vue3插槽:el-table表頭插入tooltip及更換表格背景色方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-06-06
vue頁面中使用getElementsByClassName無法獲取元素的解決
這篇文章主要介紹了vue頁面中使用getElementsByClassName無法獲取元素的解決方案,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-03-03
Vue props中Object和Array設(shè)置默認(rèn)值操作
這篇文章主要介紹了Vue props中Object和Array設(shè)置默認(rèn)值操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-07-07

