这里导入数据后,会调用主组件方法(dataUploadchildClick)用于回写主组件表格数据,列头等数据const dataUploadchildClick = (data, colunm) => {state.colunm = colunm;state.tempData = https://www.huyubaike.com/biancheng/data;getData();dataUpload.value.cancel();};2.3.2设置数据对应关系定义后台需要的列SelectData: [{key: 'zkzh', type: '', value: '', selectValue: '', title: '准考证号'},{key: 'zjlb', type: '', value: '', selectValue: '', title: '证件类别'},{key: 'zjhm', type: '', value: '', selectValue: '', title: '证件号码'},{key: 'ksxm', type: '', value: '', selectValue: '', title: '考生姓名'},{key: 'xb', type: '', value: '', selectValue: '', title: '性别'},{key: 'ss', type: '', value: '', selectValue: '', title: '省市'},{key: 'kq', type: '', value: '', selectValue: '', title: '考区'},{key: 'kdh', type: '', value: '', selectValue: '', title: '考点号'},{key: 'kdmc', type: '', value: '', selectValue: '', title: '考点名称'},{key: 'kch', type: '', value: '', selectValue: '', title: '考场号'},{key: 'kchdz', type: '', value: '', selectValue: '', title: '考场地址'},{key: 'zwh', type: '', value: '', selectValue: '', title: '座位号'},{key: 'chc', type: '', value: '', selectValue: '', title: '场次'}]创建Select组件,组件核心代码页面布局部分<label style="width: 50px;display: inline-block;">{{ itemKey }}:</label><el-select v-model="state.type" :placeholder="name" size="large" clearable><el-optionv-for="item in state.options":key="item.value":label="item.label":value="https://www.huyubaike.com/biancheng/item.value"/></el-select><el-input v-model="state.value" style="width: 200px;" :placeholder="name" size="large" v-if="state.type=='0'"/><el-select v-model="state.selectValue" style="width: 200px;" :placeholder="name" size="large" clearablev-if="state.type=='1'||state.type=='2'"><el-optionv-for="item in state.ValueOptions":key="item.key":label="item.lable":value="https://www.huyubaike.com/biancheng/item.key"/></el-select>接受参数定义props: {itemKey: String,name: String,type: String,value: String,selectValue: String,colunm: Object},页面变量定义,这里定义的默认option主要有三个
- 0 固定值,这一列为固定值,不从表格中读取
- 1 下拉框,从导入数据中选择
- 2 自动生成,这里主要是特殊业务,可以进行自定义扩展

文章插图
父页面进行引用<el-row :gutter="24" justify="start" style="text-align: left;"><div v-for="(item,index) in state.SelectData" :key='index' style="margin-top: 5px;width: 100%;"><el-col :span="24"><Select:itemKey="item.key"v-model:type="item.type"v-model:value="https://www.huyubaike.com/biancheng/item.value"v-model:selectValue="https://www.huyubaike.com/biancheng/item.selectValue":name="item.title":colunm="state.colunm"/></el-col></div></el-row>2.3.3进行数据提交提交数据到后台进行处理,这里根据自己的业务进行验证,或则进行其它扩展
经验总结扩展阅读
- 从0搭建vue3组件库: Input组件
- Vue3 企业级优雅实战 - 组件库框架 - 3 搭建组件库开发环境
- Go实现栈与队列基本操作
- 自己动手实现线程池 jdk线程池ThreadPoolExecutor工作原理解析(一)
- 我的Vue之旅 10 Gin重写后端、实现页面详情页 Mysql + Golang + Gin
- zk系列三:zookeeper实战之分布式锁实现
- 手机动态彩铃是怎么设置的(自己手机的彩铃能设置吗)
- 【深入浅出 Yarn 架构与实现】2-2 Yarn 基础库 - 底层通信库 RPC
- 11月锦鲤护航 终于能够实现心愿的3大星座
- 第2-1-5章 docker安装MinIO实现文件存储服务-springboot整合minio-minio全网最全的资料