element可編輯表格驗(yàn)證問題解決
前提:表格里設(shè)置可編輯表單。
注意事項(xiàng):
1.校驗(yàn)需要觸發(fā)表單,而表格需要時(shí)數(shù)組。因此表單綁定的是一個(gè)對象,表格中綁定的是該對象中的數(shù)組。
2.prop動態(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="活動名稱" :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: '請輸入活動名稱', 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)動態(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)文章
五分鐘教你使用vue-cli3創(chuàng)建項(xiàng)目(新手入門)
本文主要介紹了五分鐘教你使用vue-cli3創(chuàng)建項(xiàng)目,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09
vue+swiper實(shí)現(xiàn)左右滑動的測試題功能
這篇文章主要介紹了vue+swiper實(shí)現(xiàn)左右滑動的測試題功能,本文通過實(shí)例代碼給大介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-10-10
element-ui表格合并span-method的實(shí)現(xiàn)方法
這篇文章主要介紹了element-ui表格合并span-method的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-05-05
vue腳手架配置預(yù)渲染及prerender-spa-plugin配置方式
這篇文章主要介紹了vue腳手架配置預(yù)渲染及prerender-spa-plugin配置方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-05-05
Vue在echarts?tooltip中添加點(diǎn)擊事件案例詳解
本文主要介紹了Vue項(xiàng)目中在echarts?tooltip添加點(diǎn)擊事件的案例詳解,代碼具有一定的價(jià)值,感興趣的小伙伴可以來學(xué)習(xí)一下2021-11-11

