前端菜鸡流水账日记 -- 封装的table组件(ant)

哈喽哇,今天硬性分享一个我项目中的封装的table的组件以及他的使用方式之类的,为了之后用的时候可以更方便找到,话不多说直接开始

table组件:

<template><a-tableclass="ant-table-striped"size="middle":pagination="false":columns="columns":data-source="data":row-class-name="(_record, index) => (index % 2 === 1 ? 'table-striped' : null)"><template v-slot:[item]="scope" v-for="item in renderArr"><!-- // 插槽后面-slot:[item] 如果是动态渲染插槽需要使用这种方式//renderArr 是父组件传递过来的用了插槽的名字,等下会在父组件中讲清楚,通过这个数组来遍历生成插槽 --><!-- //再通过这个插槽传递数据给父组件,做一些编辑提交的操作等等 --><slot :name="item" :scope="scope" v-bind="scope || {}"></slot></template></a-table>
</template>
<script>
import { useSlots } from 'vue'
//const slots = useSlots();
export default {components: {},name: 'Select',props: {columns: { type: Array, default: () => [] },data: { type: Array, default: () => [] }},data() {return {value_: this.value,renderArr: Object.keys(useSlots())}}
}
</script>
<style lang="less" scoped>
.ant-table-striped :deep(.table-striped) td {background-color: #f0f5fa;
}
</style>

这个组件是一个使用了ant 库的可定制的表格,使用了<a-table>组件来创建一个表格

class = "ant-table-striped"表示为表格添加斑马纹样式,

size = "middle" 设置表格种的元素的大小为中等

:pagination = "false" 禁用表格的分页功能

:columns = columns 动态绑定表格列的定义

:data-source = “data” 动态绑定表格的数据源

:row-class-name 动态设置行的css类名,这里实现了每隔一行添加table-striped类以实现斑马纹效果

通过v-for = "item in renderArr " 循环渲染动态插槽,renderArr是从当前组件的插槽中动态获取的插槽名称数组,对于每一个插槽,使用<template v-solt:[item]>来动态声明插槽名,并通过:scope = “scope”传递作用域插槽数据,并且内部的<slot>标签用于将数据和作用域传递给父组件,允许父组件自定义这些插槽区域的内容,如编辑、删除等操作

并且同时引入了vue的useAolts Composition API ,用于获取组件的插槽信息,虽然没有直接用到,但是renderArr的定义依赖于它

定义了一个无组件的空对象在components属性中,意味着这个组件没有使用额外的子组件

组件名为select,并定义了两个props分别是用于接收列配置和数据源

在data() 函数中初始化组件状态:value_初始化为传入的value,虽然value并没有被明确的声明或者使用

renderArr初始化为当前组件插槽名的数组,通过Objlect.keys(useSlots()) 中获取

使用的某一个页面:

<template><!-- 一体化泵站 --><divclass="flex-col"style="height: 100%; overflow-x: hidden; overflow-y: auto"><div class="content-top-wrapper"><LayoutTop><div class="search-wrapper flex-row justify-space-between"><div><a-space><div><!-- <a-input-searchplaceholder="请输入名称"style="width: 200px"v-model:value="searchName"@search="onSearch"/> --><Selectstyle="width: 200px"v-model:value="nameValue":options="selWorkType.options":placeholder="selWorkType.placeholder"@change="selectChange"></Select></div><!-- <TimePicker style="width: 200px"></TimePicker> --><!-- <div><a-range-picker :value="timeValue" style="width: 200px" /></div> --><div><a-range-pickerv-model:value="twoTime"show-time:placeholder="['请选择开始时间', '请选择结束时间']":default-value="[dayjs().startOf('day').subtract(12, 'hour'),dayjs().endOf('day').add(12, 'hour'),]"@change="searchTwoTime"/></div></a-space></div><div><a-space><a-button type="primary" style="width: 60px" @click="jumpEchart"><template #icon><LineChartOutlined /></template></a-button><a-button type="primary" style="width: 60px" @click="Download"><template #icon><UploadOutlined /></template></a-button><!-- <a-button type="primary" style="width: 60px"><template #icon><SearchOutlined /></template></a-button> --></a-space></div></div></LayoutTop></div><div class="flex-proportion content-wrapper"><div class="table-wrapper"><Table:columns="columns":data="data":scroll="{ y: tableHeight }":loading="initLoading"><template v-slot:bodyCell="{ column, index, text }"><divv-if="['b1xy', 'b2xy', 'b3xy', 'gszzxy', 'gsfzxy'].includes(column.dataIndex)">{{text == 0? "停止": text == 1? "运行": text == 2? "故障": "--"}}</div><div v-if="['geshan'].includes(column.dataIndex)">{{text == -1? "--": text == 0? "正转": text == 1? "反转": text == 2? "停止": "故障"}}</div><divv-if="['b1lxyxtime','b1leijitime','b1dianliu','b2lxyxtime','b2leijitime','b2dianliu','b3lxyxtime','b3leijitime','b3dianliu','b1leijiqdcs','b2leijiqdcs','b3leijiqdcs','gsleijitime','gsdianliu','yewei','ssll','ljll','time',].includes(column.dataIndex)">{{ text == -1 ? "--" : text }}</div><div v-if="['b1gz', 'b2gz', 'b3gz'].includes(column.dataIndex)">{{text == -1? "--": text == 1? "变频故障": text == 2? "超温漏水故障": text == 3? "超时故障": text}}</div><div v-if="['gsgz'].includes(column.dataIndex)">{{text == -1? "--": text == 1? "故障": text == 0? "正常": text}}</div><div v-if="column.dataIndex === 'title'">{{ index + 1 }}</div><divv-if="['jsgs1','csgs1','jsgs2','csgs2','bzjs','bzcs','zlgdjsf','zildcsf','ljf',].includes(column.dataIndex)">{{text == -1? "--": text == 1? "开到位": text == 2? "关到位": text == 3? "故障": "--"}}</div><div v-if="['gsj1', 'gsj2'].includes(column.dataIndex)">{{text == -1? "--": text == 1? "运行": text == 2? "停止": text == 3? "故障": "--"}}</div><div v-if="['gsywc1', 'gsywc2'].includes(column.dataIndex)">{{ text == -1 ? "--" : "--" }}</div></template></Table></div></div><div class="pagination-wrapper"><Pagination:total="pagination.totalCount":current="pagination.current":page-size="pagination.pageSize"@onShowSizeChange="onShowSizeChange"/></div></div>
</template>
<script setup>
import { ref, reactive, createVNode } from "vue";
import { useRouter } from "vue-router";
import dayjs from "dayjs";
import {LineChartOutlined,UploadOutlined,SearchOutlined,ExclamationCircleOutlined,
} from "@ant-design/icons-vue";
import { Modal } from "ant-design-vue";
// 引入接口
import { getDataPS, getQueryName } from "../api/index";
import Select from "@/components/select/index.vue";
import LayoutTop from "../../../components/layout-top/index.vue";
import TimePicker from "@/components/time-picker/index.vue";
import Table from "@/components/table/index.vue";
import Pagination from "@/components/pagination/index.vue";
import { message } from "ant-design-vue";// 路由
const router = useRouter();
// 时间选择
const timeValue = ref();
// const twoTime = ref([null,null]);
const params = ref({});
const tableHeight = ref(document.documentElement.clientHeight - 223 + "px");
const initLoading = ref(false);
// 表格配置
const columns = reactive([{title: "序号",dataIndex: "title",width: 100,fixed: "left",align: "center",},{title: "名称",dataIndex: "name",width: 200,fixed: "left",align: "center",},{ title: "1#泵状态", dataIndex: "b1xy", width: 100, align: "center" },{ title: "2#泵状态", dataIndex: "b2xy", width: 100, align: "center" },{ title: "3#泵状态", dataIndex: "b3xy", width: 100, align: "center" },{ title: "格栅状态", dataIndex: "geshan", width: 100, align: "center" },{title: "1#泵连续运行时间",dataIndex: "b1lxyxtime",width: 200,align: "center",},{title: "1#泵累计运行时间",dataIndex: "b1leijitime",width: 200,align: "center",},{title: "1#泵电流 (A)",dataIndex: "b1dianliu",width: 100,align: "center",},{title: "2#泵连续运行时间",dataIndex: "b2lxyxtime",width: 200,align: "center",},{title: "2#泵累计运行时间",dataIndex: "b2leijitime",width: 200,align: "center",},{title: "2#泵电流 (A)",dataIndex: "b2dianliu",width: 100,align: "center",},{title: "3#泵连续运行时间",dataIndex: "b3lxyxtime",width: 200,align: "center",},{title: "3#泵累计运行时间",dataIndex: "b3leijitime",width: 200,align: "center",},{title: "3#泵电流 (A)",dataIndex: "b3dianliu",width: 100,align: "center",},{title: "1#泵累计启动次数",dataIndex: "b1leijiqdcs",width: 200,align: "center",},{title: "2#泵累计启动次数",dataIndex: "b2leijiqdcs",width: 200,align: "center",},{title: "3#泵累计启动次数",dataIndex: "b3leijiqdcs",width: 200,align: "center",},{title: "格栅累计运行时间",dataIndex: "gsleijitime",width: 200,align: "center",},{title: "格栅电流 (A)",dataIndex: "gsdianliu",width: 100,align: "center",},{ title: "液位 (m)", dataIndex: "yewei", width: 100, align: "center" },{title: "瞬时流量 (m³/h)",dataIndex: "ssll",width: 100,align: "center",},{ title: "累计流量 (m³)", dataIndex: "ljll", width: 100, align: "center" },{title: "1号格栅进水闸(G)",dataIndex: "jsgs1",width: 100,align: "center",},{title: "1号格栅出水闸(G)",dataIndex: "csgs1",width: 100,align: "center",},{title: "2号格栅进水闸(H)",dataIndex: "jsgs2",width: 100,align: "center",},{title: "2号格栅出水闸(H)",dataIndex: "csgs2",width: 100,align: "center",},{ title: "泵站进水闸(D)", dataIndex: "bzjs", width: 100, align: "center" },{ title: "泵站出水闸(D)", dataIndex: "bzcs", width: 100, align: "center" },{title: "自流管道进水阀(C)",dataIndex: "zlgdjsf",width: 100,align: "center",},{title: "自流管道出水阀(C)",dataIndex: "zildcsf",width: 100,align: "center",},{title: "自流管道及泵站出水管道连接阀(J)",dataIndex: "ljf",width: 100,align: "center",},{ title: "1号格栅机", dataIndex: "gsj1", width: 100, align: "center" },{ title: "2号格栅机", dataIndex: "gsj2", width: 100, align: "center" },{ title: "1号格栅液位差", dataIndex: "gsywc1", width: 100, align: "center" },{ title: "2号格栅液位差", dataIndex: "gsywc2", width: 100, align: "center" },{ title: "监测时间", dataIndex: "time", width: 100, align: "center" },
]);
// 分页数据
const pagination = reactive({current: 1,pageSize: 20,totalCount: null,
});
// 表格数据
const data = reactive([]);
// 获取表格数据
const getDataPSList = (current, pageSize, params) => {initLoading.value = true;getDataPS(params ? params : {}, {current: current != undefined ? current : 1,pageSize: pageSize != undefined ? pageSize : 20,}).then((res) => {// let DataPSList = res.data.result// // 数据总条数// pagination.totalCount = res.data.paging.total// for (var i in DataPSList) {//   data.push(DataPSList[i])// }// 数据总条数pagination.totalCount = res.data.data.total;data.length = 0;res.data.data.info.forEach((item) => {data.push(item);});data.map((item) => {item.b1leijiqdcs = Math.round(item.b1leijiqdcs);item.b2leijiqdcs = Math.round(item.b2leijiqdcs);item.b3leijiqdcs = Math.round(item.b3leijiqdcs);// 故障信息if (item.faultMessage == "0") {item.faultMessage = "泵故障";} else if (item.faultMessage == "1") {item.faultMessage = "栅格故障";} else if (item.faultMessage == "2") {item.faultMessage = "变频故障";} else if (item.faultMessage == "3") {item.faultMessage = "超温漏水故障";} else if (item.faultMessage == "4") {item.faultMessage = "超时故障";} else if (item.faultMessage == "5") {item.faultMessage = "无";}});console.log("一体化泵站数据", data);initLoading.value = false;});
};
getDataPSList();
// 搜索名称
const searchName = ref("");
// const onSearch = (searchValue) => {
//   data.length = 0;
//   params.name = searchValue;
//   getDataPSList(1, 20, params);
// };
const gonextTime = ref([]);
const nameValue = ref(null);
const gonextName = ref("");
const searchTwoTime = (date, time) => {gonextTime.value = time;data.length = 0;if (!date) {delete params.startTime;delete params.endTime;getDataPSList(1, 20, params);} else {params.startTime = time[0];params.endTime = time[1];getDataPSList(1, 20, params);}
};
// 分页改变是调用组件里的方法
const onShowSizeChange = (current, pageSize) => {console.log("分页改变", current, pageSize);pagination.current = current;pagination.pageSize = pageSize;data.length = 0;getDataPSList(current, pageSize, params);//   data.length = 0;// getDataPSList(current, 20)
};
// 跳转图表页面
const jumpEchart = () => {// if (!(gonextTime.length && gonextName.value)) {//     message.error("请先选择查询条件再进行查看");//     // return;// }else{//     router.push({//     name: "StationMonitorEchart",//     query: { type: "bz", time: gonextTime.value, name: gonextName.value },// });// }if (gonextTime.length == "" || gonextName.value == "") {message.error("请先选择查询条件再进行查看");return;} else {router.push({name: "StationMonitorEchart",query: {type: "bz",time: [params.startTime, params.endTime],name: gonextName.value,},});}
};
// 导出
const Download = () => {Modal.confirm({title: "您是否确定导出一体化泵站数据?",icon: createVNode(ExclamationCircleOutlined),content: createVNode("div", {style: "color:red;height:30px",}),onOk() {let encodedName;if (nameValue.value) {// 使用replace方法替换#encodedName = encodeURIComponent(nameValue.value.replace(/#/g, "%23"));} else {encodedName = nameValue.value;}const params = {name: encodedName,startTime: twoTime.value[0].format("YYYY-MM-DD HH:mm:ss"),endTime: twoTime.value[1].format("YYYY-MM-DD HH:mm:ss"),};console.log("导出", params);let url = `http://221.7.175.136:8215/api/fjj/data/DataPSExport?name=${params.name}&startTime=${params.startTime}&endTime=${params.endTime}`;window.location.href = url;// window.location.href =// "http://221.7.175.136:8215/api/fjj/data/DataPSExport";},onCancel() {console.log("Cancel");},class: "modal-pt-40",});
};
const selWorkType = reactive({placeholder: "请选择",options: [],
});
const getSelList = () => {getQueryName({ types: ["PS"] }).then((res) => {res.data.data.forEach((item) => {selWorkType.options.push({ value: item.NAME, label: item.NAME });});});
};
getSelList();
const newTime = () => {const oneDayAgo = dayjs().startOf("day");const twoDayAgo = dayjs().endOf("day");const formattedTime1 = oneDayAgo.format("YYYY-MM-DD HH:mm:ss");const formattedTime2 = twoDayAgo.format("YYYY-MM-DD HH:mm:ss");// params.value.startTime = formattedTime1;// params.value.endTime = formattedTime2;gonextTime.value = [formattedTime1, formattedTime2];
};
// 初始化时间范围选择器的值
// const twoTime = ref([
//     dayjs().startOf('day').subtract(12, 'hour'),
//     dayjs().endOf('day').add(12, 'hour'),
// ]);
const twoTime = ref([]);
const selectChange = (searchValue) => {if (searchValue) {twoTime.value = [dayjs().startOf("day"), dayjs().endOf("day")];newTime();} else {twoTime.value = []; // 若未选择或取消选择,则清空时间范围}gonextName.value = searchValue;gonextTime.value = [dayjs().startOf("day"), dayjs().endOf("day")];// 在这里重新设置默认的 24 小时时间范围//   twoTime.value = [dayjs().startOf('day'), dayjs().endOf('day')];data.length = 0;params.name = searchValue;params.startTime = gonextTime.value[0].format("YYYY-MM-DD HH:mm:ss");params.endTime = gonextTime.value[1].format("YYYY-MM-DD HH:mm:ss");getDataPSList(1, 20, params);
};
</script>
<style lang="less" scoped>
:deep(.ant-input) {height: 32px !important;border: 0;background: #f0f5fa;
}:deep(.ant-input-search-button) {height: 32px !important;border: 0;background: #f0f5fa;width: 40px !important;
}.search-wrapper {line-height: 32px;
}.content-wrapper {.table-wrapper {background: white;border-radius: 15px;height: 100%;padding: 5px;}
}.pagination-wrapper {height: 70px;padding: 10px 0;
}
</style>

使用时,就正常的按照路径引入,然后使用就可以了,定义的columns就是传给子组件的具体的内容了,在不同的引入子组件的页面中,进行不同的columns的设置就可以实现一个不完全相同的效果,当然还有一些其他的功能也都在,可以借鉴参考

这篇文章就先这样啦~~~~

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/29543.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C++ | Leetcode C++题解之第149题直线上最多的点数

题目&#xff1a; 题解&#xff1a; class Solution { public:int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}int maxPoints(vector<vector<int>>& points) {int n points.size();if (n < 2) {return n;}int ret 0;for (int i 0; i < n; i…

springboot、springcloud、springcloudalibaba版本组件之间对应关系

参考 https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E#%E6%AF%95%E4%B8%9A%E7%89%88%E6%9C%AC%E4%BE%9D%E8%B5%96%E5%85%B3%E7%B3%BB%E6%8E%A8%E8%8D%90%E4%BD%BF%E7%94%A8 毕业版本依赖关系(推荐使用) 由于 Spring Boot 3.0&…

UART基本定义、三种编程方式、freertos内怎么用、怎么封装

文章目录 串口基本概念串口的三种编程方式uart编程查询方式不常用、其他两个方式用的多中断方式&#xff1a;代码原理 DMA方式&#xff1a;配置DMA原理代码 效率最高的UART编程方式&#xff1a;是什么&#xff1f;操作 在freertos里面调用uart应该怎么做&#xff1f;代码 面向对…

uniapp canvas生成海报

效果 封装组件&#xff0c;父组件 ref 调用 downImgUrl()函数&#xff0c;其他根据自己需求改 <template><view><view class"bgpart"><canvas class"canvas-wrap" canvas-id"canvasID" type"2d"></canvas…

Python程序设计 文件和异常 笔记整理

第七章 1.文件读写 步骤&#xff1a;打开文件→处理数据→关闭文件 2.open函数 fileobj open(filename,mode) fileobj是open()返回的文件对象 filename是该文件的文件名 mode&#xff08;例如rt&#xff09;是指明操作&#xff08;第一个字母表示对其的操作&#xff0c;例如…

jsp运行提示_jsp.java某行存在错误问题的解决

jsp运行提示XXX_jsp.java某行存在错误问题的解决 在编译运行jsp文件时&#xff0c;出现类似如下提示&#xff1a; 49行发生错误&#xff0c;要注意&#xff1a; 这里所指的49行并非jsp文件的第49行&#xff0c;而是编译后的jsp.java文件的第49行。 因此&#xff1a;解决问题…

saas考试系统和私有化考试系统的区别

SaaS考试系统和私有化考试系统&#xff0c;作为现代信息化教育的重要工具&#xff0c;各有其独特的优势和特点。本文将从多个维度对这两种系统进行深入剖析&#xff0c;以揭示它们之间的核心差异。 首先&#xff0c;从部署方式来看&#xff0c;SaaS考试系统是基于云服务的在线考…

STM32--IAP程序升级实验

1. STM32程序升级方法 1.1 ST-link / J-link下载 将编译生成的hex文件使用ST-Link/J-Link工具直接下载进 Flash 即可。Keil中点击下载也能一键下载。下载后的代码会存放在Flash的起始地址0x0800 0000处。 简单补充一句&#xff0c;bin文件和hex文件的区别&#xff1a; bin文…

论坛产品选型,需要关注哪些点?

论坛社区是一个经久不衰的行业&#xff0c;比如我们常见的宠物社区&#xff0c;校园社区&#xff0c;游戏社区、企业内部社区&#xff0c;品牌社区&#xff0c;本地同城、私域社区项目、付费社群、问答社区等等&#xff0c;可以说是覆盖了各行各业&#xff0c;那么如果我们要搭…

Python实现管线建模 - 3.同心变径管

往期回顾 Python实现管线建模 || 1.圆直管、方管https://blog.csdn.net/Xxy9426/article/details/138836778?spm1001.2014.3001.5501 对依赖库的补充 随着后续内容的深入&#xff0c;我发现单纯靠trimesh库已经无法完成后续的建模&#xff08;涉及到多个几何体拼接或者是创建…

article:文章信息表

1、article&#xff1a;文章信息表 序号名称描述类型1id主键varchar(40)2user_id发布者用户idvarchar(40)3nick_name发布者用户昵称varchar(40)4user_image发布者头像urlvarchar(255)5title文章标题varchar(255)

MySQL入门学习-子查询.EXISTS

子查询 EXISTS 是 MySQL 中的一种子查询类型&#xff0c;用于检查子查询结果集是否为空。如果子查询结果集不为空&#xff0c;则 EXISTS 子查询返回 TRUE&#xff1b;否则&#xff0c;返回 FALSE。 子查询 EXISTS 的特点是它只关心子查询结果集是否为空&#xff0c;而不关心结果…

全域外卖系统源码在哪搭建?哪家公司的系统源码最值得推荐

随着全域外卖的兴起&#xff0c;全域外卖系统源码搭建逐渐在众多全域外卖赛道的入局方式中脱颖而出。但是&#xff0c;就目前多个创业者社群就这一话题的讨论程度来看&#xff0c;绝大多数创业者对于全域外卖系统源码搭建模式的了解都仅仅停留在“是什么”层面&#xff0c;而对…

Conmi的正确答案——Vue默认加载方式设置为Yarn后怎么修改

Vue版本&#xff1a;3 1和2主要是搜索文件所在位置&#xff0c;Windows的这个文件一般在“C:\User{当前用户}”下&#xff0c;linux的非root情况下一般在“/home/{当前用户}”下。 1、打开“Everything”&#xff1b; 2、搜索“vuerc”&#xff1b; 3、打开“.vuerc”&#xf…

Boom3D软件下载-Boom3D音效增强工具下载附加详细安装步骤

Boom3D音效增强工具是一款便捷的为用户们进行音频处理和编辑的软件&#xff0c;支持用户们轻松的进行音频的使用&#xff0c;支持超多的音频格式让你可以轻松的进行使用&#xff0c;Boom3D音效增强工具拥有多种音频特效的功能&#xff0c;让你可以在Boom3D音效增强工具轻松的进…

关于scrapy模块中setting.py文件的介绍

作用 在Scrapy框架中&#xff0c;settings.py 文件起着非常重要的作用&#xff0c;它用于配置和控制整个Scrapy爬虫项目的行为、性能和功能。 setting.py文件的介绍 # Scrapy settings for haodaifu project # # For simplicity, this file contains only settings consider…

Linux时间子系统5:timekeeper、timecountercyclecounter

1. 前言 前面我们介绍了用户态获取时间的接口clock_gettime&#xff0c;时钟的种类posix_clocks以及时钟源clocksource。那么我们思考这样一个问题&#xff0c;无论clock_gettime或者posix_clock定义的时间都是相对于某个起始点的时间&#xff0c;即相对于Linux Epoch的秒数&am…

无sudo权限安装tmux

方法 1: 从源码编译安装 tmux (未测试) 下载并解压源码 首先&#xff0c;下载 tmux 的源码并解压。你可以从 tmux releases page 获取最新版本的 tarball。 wget https://github.com/tmux/tmux/releases/download/3.3a/tmux-3.3a.tar.gz tar -xzvf tmux-3.3a.tar.gz cd tmux…

web前端开发项目教学:深入剖析四大核心、五大技能、六大实战、七大建议

web前端开发项目教学&#xff1a;深入剖析四大核心、五大技能、六大实战、七大建议 在数字化的今天&#xff0c;Web前端开发已成为一项不可或缺的技能。无论是初学者还是有一定经验的开发者&#xff0c;都需要通过系统的项目教学来提升自己的技能水平。本文将围绕Web前端开发项…

pytorch安装----CPU版本

在安装之前&#xff0c;需要先配置GPU环境&#xff08;安装CUDA和CudaNN) 命令行输入nvidia-smi&#xff0c;查看驱动信息 安装相应的CUDA 和CUDANN 验证&#xff1a;输入nvcc --version 或者nvcc -V 进行检查 在anaconda里创建环境 conda create -n py39gpu python3.9激活环…