当前位置: 首页 > news >正文

Vue3+ElementUI中的Table组件的使用

Vue3+ElementUI中的Table组件的使用

    • 校验
      • 表格内多个输入框校验
    • 表格滚动到底部

校验

表格内多个输入框校验

  1. 注意prop如何写。
  2. 实现:一旦输入框内部有更改,清空校验;
  3. 实现:自定义校验错误提示信息样式;
  4. 实现:在校验中获取该行数据;
<template><el-table :data="inputTableData" max-height="286"><el-table-column type="index" label="#" align="center" width="80" /><el-table-column prop="name" label="产品名称" align="center" width="180"><template #default="scope"><el-form-item :prop="`${scope.$index}.name`" :rules="inputTableRules(scope.row).name"><el-input type="text" v-model="scope.row.name" @input="clearValidateStatus(scope.$index, 0)"></el-input><template v-slot:error="{ error }"><el-tooltip effect="light" :content="error" placement="top"><el-icon class="custom-error-tip"><WarningFilled /></el-icon></el-tooltip></template></el-form-item></template></el-table-column><el-table-column prop="price" label="price" align="center"><template #default="scope"><el-form-item :prop="`${scope.$index}.price`" :rules="inputTableRules(scope.row).price"><el-input type="text" v-model="scope.row.L" @input="clearValidateStatus(scope.$index, 1)"></el-input><template v-slot:error="{ error }"><el-tooltip effect="light" :content="error" placement="top"><el-icon class="custom-error-tip"><WarningFilled /></el-icon></el-tooltip></template></el-form-item></template></el-table-column></el-table>
</template><script lang="ts" setup>
const inputTableRules = (row) => {return {name: [{ validator: validateInputTableName, rowData: row, trigger: [] }],L: [{ validator: validateNumber, rowData: row, trigger: [] }],A: [{ validator: validateNumber, rowData: row, trigger: [] }],B: [{ validator: validateNumber, rowData: row, trigger: [] }]}
}const clearValidateStatus = (rowIndex, columnIndex) => {let columnLength = 4;let itemIndex = rowIndex * columnLength + columnIndexinputTableRuleFormRef.value.fields[itemIndex].clearValidate();
}
</script>

表格滚动到底部

// 表格滚动到底部
export const tableScrollToBottom = (tableRef) => {if (tableRef) {let maxHeight = tableRef.layout.table.refs.bodyWrapper.firstElementChild.firstElementChild.firstElementChild.clientHeight;tableRef.setScrollTop(maxHeight);}
}
http://www.lryc.cn/news/424648.html

相关文章:

  • Highcharts 条形图:数据可视化的利器
  • 嵌入式初学-C语言-二四
  • tcpdump入门——每种flag分别表示什么意思
  • Qt如何封装工具
  • vue3进阶用法之通过调用函数动态加载组件用法及示例
  • 线程和进程的关系
  • 《AI视频类工具之十二——​ EbSynth》
  • Facebook国内企业户、海外户、国内二不限户以及三不限户区别何在?
  • 修改 ASP.NET Core 应用程序运行后的默认端口
  • 维基知识库系统Wiki.js本地Linux环境部署并配置公网地址远程访问
  • 010集——按值传递、按引用传递等方法——C#学习笔记
  • Linux系统调优技巧
  • 计算机学习
  • 数字医学影像系统PACS源码,三甲以下医院都能满足,C#语言开发,C/S架构系统成熟稳定,支持二次开发项目使用。
  • C++语言基础|循环结构
  • 【学习笔记】解决在声音输出中找不到蓝牙耳机设备的问题
  • PPPoE基础笔记
  • 开发组日志记录SPEC_v0.1.0
  • MySQL8 innoDB引擎的精髓
  • 【C语言实现花屏效果并打包程序为exe可执行文件】
  • 数据结构——排序(2):选择排序+交换排序
  • jenkins升级踩坑记录
  • mysql笔记第二篇
  • Facebook的区块链技术:提升数据安全与隐私保护
  • ⌈ 传知代码 ⌋ Visual SLAM函数
  • Vue组件之间的通信
  • 【AI 绘画】模型转换与快速生图(基于diffusers)
  • 甄选范文“论软件设计方法及其应”软考高级论文系统架构设计师论文
  • leetcode线段树(2940. 找到 Alice 和 Bob 可以相遇的建筑)
  • 用于不平衡医疗数据分类的主动SMOTE