当前位置: 首页 > 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.mrgr.cn/news/729.html

相关文章:

  • 《SQL 中计算地理坐标两点间距离的魔法》
  • 《Ubuntu22.04环境下的ROS2学习笔记2》
  • WordPress 中 cURL 请求出现 504 网关超时错误的解决方法
  • 借助Vercel 十分钟搭建属于自己的AI应用站点
  • qt-17不规则窗体
  • 【微信小程序】生命周期
  • 数据结构——单链表
  • 【uni-app】使用天气API做一个天气APP(全过程)- 实况、逐小时、40日
  • Qt/QML学习-Dial
  • 贪心算法---跳跃游戏
  • 牛客网SQL 练习二
  • SpringBoot的事务/调度/缓存/邮件发送和一些Spring知识点总结
  • 虚幻5|布料模拟
  • 机器学习——全连接(MLP多层感知机)的理解
  • LLMs之Llama Coder:llama-coder的简介、安装和使用方法、案例应用之详细攻略
  • 一键运行RocketMQ5.3和Dashboard
  • 高可用负载均衡集群
  • C++的序列容器——数组
  • Docker Containerd初体验
  • 博达网站群管理平台 v6.0使用相关问题解决