【VUE】Vue中实现树状表格结构编辑与版本对比的详细技术实现

Vue中实现树状表格结构编辑与版本对比的详细技术实现

在Vue中,创建一个可编辑的树状表格并实施版本对比功能是一种需求较为常见的场景。在本教程中,我们将使用Vue结合Element UI的el-table组件,来构建一个树状表格,其中包含添加、编辑功能,并通过特定的方法展示数据变更。本文会详继解析每一步的代码实现。

图中,黄色为修改的数据,绿色为新增,红色是被删除的数据。
在这里插入图片描述

初始设置与组件

首先,我们使用el-table组件创建基础的表格,并通过tree-props属性指定了如何展示树形数据的结构。

<template>
  <div class="h-station">
    <el-card class="h-card">
      <el-button type="primary" @click="addScheme">添加一级分类</el-button>
      <el-button type="primary">批量导入</el-button>
      <el-table
        :data="tableData"
        :row-class-name="getRowClass"
        style="width: 100%; margin-top: 15px"
        border
        height="calc(100vh - 260px)"
        row-key="id"
        :tree-props="{ children: 'children' }">
        <el-table-column align="center" prop="name" label="维修方案名称" min-width="100px">
          <template slot-scope="scope">
            <el-input
              v-if="scope.row.type !== 'Button'"
              style="width: calc(100% - 50px)"
              v-model="scope.row.name"
              :disabled="scope.row.type === 'delete'">
            </el-input>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

数据模型和方法定义

data函数中定义的tableData数组,包含了表格数据和结构信息。此外,我们会备份原始数据以供版本对比之用。

<script>
export default {
  data() {
    return {
      rawData: [],
      tableData: [...],
      curMateral: { children: [] },
      materials: [],
      materialsTypeIds: [],
      materialsTypeNames: [],
    };
  },
  created() {
    this.rawData = JSON.parse(JSON.stringify(this.tableData));
    this.loadMaterialsInfo();  // 模拟加载物料信息
  },
  methods: {
    enrichDataWithLevel(data, level = 1, parent = null) {
      return data.map(item => ({
        ...item,
        level,
        children: item.children ? this.enrichDataWithLevel(item.children, level + 1, item) : [],
        parent,
      }));
    },
    // 示例方法:模拟加载物料信息
    loadMaterialsInfo() {
      this.materials = [{ materialsTypeId: 1, materialsTypeName: '物料1' }];
      this.curMateral = this.materials[0];
    },
  }
};
</script>

版本对比的展示实现

我们通过getRowClass方法为表格行动态赋予样式,标识数据的更改状态:新添加、更改或删除。

methods: {
  getRowClass({ row, rowIndex }) {
      let rawNode = this.findNodeById(this.rawData, row.id);
      if (row.type === 'delete') {
        return 'deleted-row';
      } else if (row.id.includes && row.id.includes('cwx-') && row.type !== 'Button') {
        return 'new-row';
      } else if (rawNode) {
        let flag = true;
        if (rawNode&&!(row.id+'').includes('cwx-')) {
          let keys = Object.keys(rawNode);
          keys.push('materialsTypeIds')
          for (let key of keys) {
            if(key==='materialsTypeIds'){
                if((!rawNode.materialsTypeIds||rawNode.materialsTypeIds.length===0)&&(!row.materialsTypeIds||row.materialsTypeIds.length===0)){
                }else{
                    flag=false
                }
            }
            else if (rawNode[key] !== row[key]&&(key!=='parent')&&(key!=='children')) {
              flag = false;
            }
          }
        }
        if(!flag){
            return 'change-row';
        }
      }
    },
}

样式定义

使用SCSS来定义不同状态下行的样式:

<style scoped>
::v-deep .change-row {
  background-color: rgba(230,162,60,0.2);
}
::v-deep .el-table--enable-row-hover .el-table__body .change-row:hover > td.el-table__cell {
    background-color: rgba(230,162,60,0.2);
}
::v-deep .new-row {
  background-color: rgba(103, 194, 58, 0.2);
}
::v-deep .el-table--enable-row-hover .el-table__body .new-row:hover > td.el-table__cell {
  background-color: rgba(103, 194, 58, 0.2);
}
::v-deep .deleted-row {
  background-color: rgba(245, 108, 108, 0.2);
}
::v-deep .deleted-row::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%; /* 置于行的中间 */
  width: 100%; /* 线的宽度为整行 */
  border-top: 1px solid #000; /* 红色的线,你可以调整颜色和线的样式 */
  opacity: 0.7; /* 线的透明度,你可以调整它使线更清晰或更隐蔽 */
}
::v-deep .el-table .el-table__row {
  position: relative;
}
::v-deep .el-table--enable-row-hover .el-table__body .deleted-row:hover > td.el-table__cell {
  background-color: rgba(245, 108, 108, 0.2);
}
</style>

完整代码实现

<template>
  <div class="h-station">
    <el-card class="h-card">
      <el-button type="primary" @click="addScheme">添加一级分类</el-button>
      <el-button type="primary">批量导入</el-button>
      <el-table
        :row-class-name="getRowClass"
        :data="tableData"
        style="width: 100%; margin-top: 15px"
        border
        height="calc(100vh - 260px)"
        row-key="id"
        :tree-props="{ children: 'children' }"
      >
        <el-table-column align="center" prop="name" label="维修方案名称" min-width="100px">
          <template slot-scope="scope">
            <el-input
              v-if="scope.row.type !== 'Button'"
              style="width: calc(100% - 50px)"
              v-model="scope.row.name"
              :disabled="scope.row.type === 'delete'"
            ></el-input>
            <el-button v-else type="primary" :disabled="tableData.find((item) => item.id === scope.row.parent.id).type==='delete'" @click="addSubScheme(scope.row)">添加子方案</el-button>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="state" label="状态" min-width="30px">
          <template slot-scope="scope">
            <el-switch
              v-if="scope.row.level === 0"
              v-model="scope.row.state"
              active-color="#199f7e"
              inactive-color="#eee"
            >
            </el-switch>
            <span v-else-if="scope.row.type === 'Button'"></span>
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column align="center" show-overflow-tooltip prop="wlz" label="物料组">
          <template slot-scope="scope">{{
            getMaterialsNameStr(getMaterialsName(scope.row.materialsTypeIds || []))
          }}</template>
        </el-table-column>
        <el-table-column align="center" prop="cjsj" label="创建时间" min-width="60px"> </el-table-column>
        <el-table-column align="center" prop="handle" label="操作" min-width="40px">
          <template slot-scope="scope">
            <template v-if="scope.row.type !== 'Button'">
              <template v-if="scope.row.type === 'delete'">
                <el-button type="text" @click="revokeDeleteScheme(scope.row)">撤销删除</el-button>
              </template>
              <template v-else>
                <el-button v-if="scope.row.level > 0" type="text" @click="relatedMaterials(scope.row)"
                  >关联物料</el-button
                >
                <el-button type="text" @click="deleteScheme(scope.row)">删除</el-button>
              </template>
            </template>
          </template>
        </el-table-column>
      </el-table>
      <p style="text-align: center;margin-top: 20px;">
        <el-button type="primary">保存更改</el-button>
        <el-button>返回</el-button>
        </p>
    </el-card>
    <common-dialog
      title="关联物料组"
      :visible="visible"
      width="700px"
      confirmText="保存"
      :loading="btnloading"
      :handleClose="handleClose"
      :handleConfirm="handleConfirm"
    >
      <div style="width: 100%; overflow: hidden">
        <el-row :gutter="20">
          <el-col :span="3">
            <p style="margin-top: 30px">物料组:</p>
          </el-col>
          <el-col :span="10">
            <p class="mb10">物料组</p>
            <div class="select-box">
              <p v-for="item in materials" :key="item.materialsTypeId" :class="{'cur-materials': item.materialsTypeId===curMateral.materialsTypeId}" class="materials" @click="selectMateral(item)">
                <span>{{ item.materialsTypeName }}</span>
                <i class="el-icon-arrow-right"></i>
              </p>
            </div>
          </el-col>
          <el-col :span="11">
            <p class="mb10">二级分类</p>
            <div class="select-box">
              <el-checkbox-group v-model="materialsTypeIds" @change="changeMaterialsTypes">
                <p v-for="item in curMateral.children" :key="item.materialsTypeId">
                  <el-checkbox :label="item.materialsTypeId">{{ item.materialsTypeName }}</el-checkbox>
                </p>
              </el-checkbox-group>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20" style="margin-top: 15px">
          <el-col :span="3">
            <p>已关联物料组:</p>
          </el-col>
          <el-col :span="21">
            <div class="select-box h150">
              <p v-for="(item, index) in materialsTypeNames" :key="index">{{ item }}</p>
            </div>
          </el-col>
        </el-row>
      </div>
    </common-dialog>
  </div>
</template>

<script>
import commonDialog from '@/components/CommonDialog/index';
import { getSecondaryClassi } from '@/api/sparePartsManagement/basic/materialsInfo.js';
export default {
  components: { commonDialog },
  data() {
    return {
      rawData: [],
      tableData: [
        {
          id: 1,
          name: '123',
          state: true,
          children: [
            { id: 10, name: '10' },
            { id: 11, name: '11' },
          ],
        },
        {
          id: 2,
          name: '222',
          state: true,
          children: [],
        },
      ],
      visible: false,
      btnloading: false,
      curRow: null,
      curMateral: {
        children: [],
      },
      materials: [],
      materialsTypeIds: [],
      materialsTypeNames: [],
    };
  },
  created() {
    this.tableData = this.enrichDataWithLevel(this.tableData);
    this.rawData = JSON.parse(JSON.stringify(this.tableData));
    this.getMaterialsInfo();
  },
  methods: {
    findNodeById(tree, id) {
      for (let i = 0; i < tree.length; i++) {
        if (tree[i].id === id) {
          return tree[i];
        }
        if (tree[i].children && tree[i].children.length) {
          const found = this.findNodeById(tree[i].children, id);
          if (found) {
            return found;
          }
        }
      }
      return null; // 如果在树中找不到该节点
    },
    getRowClass({ row, rowIndex }) {
      let rawNode = this.findNodeById(this.rawData, row.id);
      if (row.type === 'delete') {
        return 'deleted-row';
      } else if (row.id.includes && row.id.includes('cwx-') && row.type !== 'Button') {
        return 'new-row';
      } else if (rawNode) {
        let flag = true;
        if (rawNode&&!(row.id+'').includes('cwx-')) {
          let keys = Object.keys(rawNode);
          keys.push('materialsTypeIds')
          for (let key of keys) {
            if(key==='materialsTypeIds'){
                if((!rawNode.materialsTypeIds||rawNode.materialsTypeIds.length===0)&&(!row.materialsTypeIds||row.materialsTypeIds.length===0)){
                }else{
                    flag=false
                }
            }
            else if (rawNode[key] !== row[key]&&(key!=='parent')&&(key!=='children')) {
              flag = false;
            }
          }
        }
        if(!flag){
            return 'change-row';
        }
      }
    },
    changeMaterialsTypes() {
      this.materialsTypeNames = this.getMaterialsName(this.materialsTypeIds);
    },
    getMaterialsNameStr(arr) {
      return arr.join(';');
    },
    getMaterialsName(ids) {
      let nodes = this.findNodesById({ children: this.materials, materialsTypeId: -1 }, ids);
      let tree = [];
      for (let node of nodes) {
        let parentNode = this.materials.find((item) => item.materialsTypeId === node.parentId);
        let treeIndex = tree.findIndex((item) => item.materialsTypeId === parentNode.materialsTypeId);
        if (treeIndex === -1) {
          tree.push({ ...parentNode, children: [node] });
        } else {
          tree[treeIndex].children.push(node);
        }
      }
      let arr = [];
      for (let parent of tree) {
        let str = parent.materialsTypeName + ':';
        let childs = parent.children.map((item) => item.materialsTypeName).join('、');
        str += childs;
        arr.push(str);
      }
      return arr;
    },
    findNodesById(tree, ids) {
      // 定义一个结果数组来存储找到的节点
      let result = [];
      // 定义一个递归函数用于在树中找到具有特定id的节点
      function searchTree(node, ids) {
        // 如果当前节点的id在ids数组中,那么把节点按照ids的顺序加入结果数组
        const index = ids.indexOf(node.materialsTypeId);
        if (index !== -1) {
          result[index] = node;
        }

        // 如果当前节点有子节点,递归搜索每个子节点
        if (node.children && node.children.length) {
          node.children.forEach((child) => searchTree(child, ids));
        }
      }
      // 开始从树的根节点开始递归搜索
      searchTree(tree, ids);
      // 过滤掉结果数组中的未定义项,并返回结果
      return result.filter((node) => node !== undefined);
    },
    selectMateral(item) {
      this.curMateral = item;
    },
    getMaterialsInfo() {
      getSecondaryClassi().then((res) => {
        this.materials = res.data;
      });
    },
    relatedMaterials(row) {
      this.curRow = row;
      this.materialsTypeIds = [...(this.curRow?.materialsTypeIds || [])];
      this.changeMaterialsTypes();
      this.visible = true;
    },
    handleClose() {
      this.visible = false;
      this.curRow = null;
      this.curMateral = {
        children: [],
      };
    },
    handleConfirm() {
      this.$set(this.curRow, 'materialsTypeIds', [...this.materialsTypeIds]);
      this.handleClose();
    },
    deleteScheme(row) {
      if (row.id.includes && row.id.includes('cwx-')) {
        this.deleteNode(this.tableData, row.id);
      } else {
        this.$set(row, 'type', 'delete');
        if(row.children){
            for(let item of row.children){
                if(item.type!=='Button'){
                    this.$set(item, 'type', 'delete');
                }
            }
        }
      }
    },
    deleteNode(data, id) {
      for (let i = 0; i < data.length; i++) {
        if (data[i].id === id) {
          // 直接从数组中删除
          data.splice(i, 1);
          return true; // 表示删除完成
        }
        if (data[i].children && data[i].children.length > 0) {
          // 递归调用删除函数
          if (this.deleteNode(data[i].children, id)) {
            if (data[i].children.length === 0) {
              // 如果子数组为空,则删除子数组属性
              delete data[i].children;
            }
            return true;
          }
        }
      }
      return false;
    },
    revokeDeleteScheme(row) {
      this.$set(row, 'type', '');
      if(row.children){
            for(let item of row.children){
                if(item.type!=='Button'){
                    this.$set(item, 'type', '');
                }
            }
        }
    },
    addScheme() {
      let now = new Date().valueOf();
      let item = {
        id: 'cwx-' + now, //id 为 cwx-xxx这种格式的均为临时id,和后端返回的id隔离
        name: '',
        state: true,
        wlz: '',
        cjsj: '',
        level: 0,
        parent: null,
        children: [],
      };
      item.children.push({
        id: 'cwx-' + now + 1, //id 为 cwx-xxx这种格式的均为临时id,和后端返回的id隔离
        type: 'Button',
        level: 1,
        parent: item,
      });
      this.tableData.push(item);
    },
    addSubScheme(row) {
      let parent = this.tableData.find((item) => item.id === row.parent.id);
      let now = new Date().valueOf();
      parent.children.splice(-1, 0, {
        id: 'cwx-' + now, //id 为 cwx-xxx这种格式的均为临时id,和后端返回的id隔离
        name: '',
        state: true,
        wlz: '',
        cjsj: '',
        level: 1,
        parent: row.parent,
      });
    },
    enrichDataWithLevel(data, level = 0, parent = null) {
      let list = data.map((item) => ({
        ...item,
        level: level,
        children: item.children ? this.enrichDataWithLevel(item.children, level + 1, item) : null,
        parent: parent,
      }));
      if (level === 1) {
        let now = new Date().valueOf();
        list.push(
          //添加按钮节点
          {
            id: 'cwx-' + now, //id 为 cwx-xxx这种格式的均为临时id,和后端返回的id隔离
            type: 'Button',
            parent: parent,
          }
        );
      }
      return list;
    },
  },
};
</script>

<style lang="scss" scoped>
p {
  margin: 0;
}
::v-deep .change-row {
  background-color: rgba(230,162,60,0.2);
}
::v-deep .el-table--enable-row-hover .el-table__body .change-row:hover > td.el-table__cell {
    background-color: rgba(230,162,60,0.2);
}
::v-deep .new-row {
  background-color: rgba(103, 194, 58, 0.2);
}
::v-deep .el-table--enable-row-hover .el-table__body .new-row:hover > td.el-table__cell {
  background-color: rgba(103, 194, 58, 0.2);
}
::v-deep .deleted-row {
  background-color: rgba(245, 108, 108, 0.2);
}
::v-deep .deleted-row::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%; /* 置于行的中间 */
  width: 100%; /* 线的宽度为整行 */
  border-top: 1px solid #000; /* 红色的线,你可以调整颜色和线的样式 */
  opacity: 0.7; /* 线的透明度,你可以调整它使线更清晰或更隐蔽 */
}
::v-deep .el-table .el-table__row {
  position: relative;
}
::v-deep .el-table--enable-row-hover .el-table__body .deleted-row:hover > td.el-table__cell {
  background-color: rgba(245, 108, 108, 0.2);
}
.select-box {
  padding: 10px;
  height: 200px;
  border: 1px solid #eee;
  overflow: auto;
}

.materials {
  line-height: 25px;
  padding: 0 15px;
  cursor: pointer;

  span {
    display: inline-block;
    vertical-align: middle;
    width: calc(100% - 16px);
    overflow: hidden; //超出的文本隐藏
    text-overflow: ellipsis; //溢出用省略号显示
    white-space: nowrap; //溢出不换行
  }
}
.cur-materials{
    background-color: rgba(25,159,126,0.41);
}

.h150 {
  height: 150px;
}

.mb10 {
  margin-bottom: 10px;
}
</style>

总结

通过这种方式,我们不仅提供了树状表格数据的编辑功能,还实现了通过颜色和样式标识不同版本之间数据变动的可视化展示。这使得数据的对比和审核变得直观和高效。

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

ICCV 2021 | FcaNet: Frequency Channel Attention Networks 中的频率分析

ICCV 2021 | FcaNet: Frequency Channel Attention Networks 中的频率分析 论文&#xff1a;https://arxiv.org/abs/2012.11879代码&#xff1a;https://github.com/cfzd/FcaNet 文章是围绕 2D 的 DCT 进行展开的&#xff0c;本文针对具体的计算逻辑进行梳理和解析。 f ( u ,…

【MySQL精炼宝库】数据库的约束 | 表的设计 | 聚合查询 | 联合查询

目录 一、数据库约束 1.1 约束类型&#xff1a; 1.2 案例演示&#xff1a; 二、表的设计 2.1 一对一: 2.2 一对多: 2.3 多对多: 2.4 内容小结&#xff1a; 三、新增 四、查询 4.1 聚合查询&#xff1a; 4.1.1 聚合函数&#xff1a; 4.1.2 GROUP BY子句&#xff1a…

linux使用docker 安装mysql redis

linux安装docker https://hub-stage.docker.com/ 前往这里搜索容器来部署。每个容器都有独立的运行环境。 具体安装教程 https://docs.docker.com/engine/install/centos/#install-using-the-repository 检查是否安装成功&#xff1a; sudo docker --version 配置国内镜像加速…

人脸识别概念解析

目录 1. 概述 2. 人脸检测 3. 人脸跟踪 4. 质量评价 5. 活体检测 6. 特征提取 7. 人脸验证 8. 人脸辨识 1. 概述 人脸识别在我们的生活中随处可见&#xff0c;例如在大楼门禁系统中&#xff0c;它取代了传统的门禁卡或密码&#xff0c;提高了进出的便捷性和安全性。在商…

Adfind的使用

Adfind是一个使用C语言写的活动目录查询工具&#xff0c;它允许用户轻松地搜索各种活动目录信息。它不需要安装&#xff0c;因为它是基于命令行的。它提供了许多选项&#xff0c;可以细化搜索并返回相关细节。下面讲解Adfind的参数以及其使用。 参数 执行如下命令即可查看Adf…

ruoyi-nbcio-plus基于vue3的flowable为了适配文件上传改造VForm3的代码记录

更多ruoyi-nbcio功能请看演示系统 gitee源代码地址 前后端代码&#xff1a; https://gitee.com/nbacheng/ruoyi-nbcio 演示地址&#xff1a;RuoYi-Nbcio后台管理系统 http://218.75.87.38:9666/ 更多nbcio-boot功能请看演示系统 gitee源代码地址 后端代码&#xff1a; h…

Flutter笔记:DefaultTextStyle和DefaultTextHeightBehavior解读

Flutter笔记 DefaultTextStyle和DefaultTextHeightBehavior解读 - 文章信息 - Author: 李俊才 (jcLee95) Visit me at CSDN: https://jclee95.blog.csdn.netMy WebSite&#xff1a;http://thispage.tech/Email: 291148484163.com. Shenzhen ChinaAddress of this article:htt…

PriorityQueue—优先级队列FollowUp

FollowUp大纲&#xff1a; 思维导图&#xff1a; FollowUp PriorityQueue: Q1&#xff1a;但不知道是大根堆化石小根堆 A&#xff1a;Q1 只需要放进去几个元素peek&#xff08;&#xff09;出元素是大的还是小的 下面如果是5就是小根堆10就是大根堆 A&#xff1a;默认是小根…

Github创建远程仓库(项目)

天行健&#xff0c;君子以自强不息&#xff1b;地势坤&#xff0c;君子以厚德载物。 每个人都有惰性&#xff0c;但不断学习是好好生活的根本&#xff0c;共勉&#xff01; 文章均为学习整理笔记&#xff0c;分享记录为主&#xff0c;如有错误请指正&#xff0c;共同学习进步。…

OPPO Reno10Pro/Reno11/K10手机强解BL刷root权限KSU内核抓包刷机救砖

OPPO Reno10Pro/Reno11/K10手机虽然发布时间并不久&#xff0c;但由于天玑处理器的体质&#xff0c;已经支持强制解锁BL了&#xff0c;该漏洞来自第三方工具适配&#xff0c;支持OPPO天机8100/8200刷机救砖解锁BL不需要等待官方深度测试直接实现。解锁BL后的OPPO Reno10Pro/Ren…

华为ensp中BGP(边界网关协议)基础原理及配置命令

作者主页&#xff1a;点击&#xff01; ENSP专栏&#xff1a;点击&#xff01; 创作时间&#xff1a;2024年4月27日10点04分 BGP&#xff08;边界网关协议&#xff09;是一种路由协议&#xff0c;用于在互联网中的不同自治系统&#xff08;AS&#xff09;之间交换路由信息。它…

Edge浏览器新特性深度解析,写作ai免费软件

首先&#xff0c;这篇文章是基于笔尖AI写作进行文章创作的&#xff0c;喜欢的宝子&#xff0c;也可以去体验下&#xff0c;解放双手&#xff0c;上班直接摸鱼~ 按照惯例&#xff0c;先介绍下这款笔尖AI写作&#xff0c;宝子也可以直接下滑跳过看正文~ 笔尖Ai写作&#xff1a;…

运算符重载(2)

1.赋值运算符重载 #include<iostream> using namespace std;class Person { friend void test01(); public:Person(int age){m_Age new int(age);}/*堆区的数据由程序员手动开辟并手动释放*/~Person(){if (m_Age ! NULL){delete m_Age;}}Person& operator(Person &a…

如此建立网络根文件系统 Mount NFS RootFS

安静NFS系统服务 sudo apt-get install nfs-kernel-server 创建目录 sudo mkdir /rootfsLee 将buildroot编译的根文件系统解压缩到 sudo tar xvf rootfs.tar -C /rootfsLee/ 添加文件NFS访问路径 sudo vi /etc/exports sudo /etc/exports文件&#xff0c;添加如下一行 …

比 PSD.js 更强的下一代 PSD 解析器,支持 WebAssembly

比 PSD.js 更强的下一代 PSD 解析器&#xff0c;支持 WebAssembly 1.什么是 webtoon/ps webtoon/ps 是 Typescript 中轻量级 Adobe Photoshop .psd/.psb 文件解析器&#xff0c;对 Web 浏览器和 NodeJS 环境提供支持&#xff0c;且做到零依赖。 Fast zero-dependency PSD par…

创建SpringBoot和RabbitMQ的整合项目

文章目录 创建SpringBoot和RabbitMQ的整合项目首先快速创建一个maven项目引入SpringBoot整合rabbitMQ的依赖在src/main目录下创建resources目录并引入配置文件写消息发送者MessageSender写消息接收者MessageReceiver写RabbitMQConfig配置类写SpringBoot启动主类CommandLineRunn…

决策树模型示例

通过5个条件判定一件事情是否会发生&#xff0c;5个条件对这件事情是否发生的影响力不同&#xff0c;计算每个条件对这件事情发生的影响力多大&#xff0c;写一个决策树模型pytorch程序,最后打印5个条件分别的影响力。 一 决策树模型是一种非参数监督学习方法&#xff0c;主要…

Java高阶私房菜:JVM垃圾回收机制及算法原理探究

目录 垃圾回收机制 什么是垃圾回收机制 JVM的自动垃圾回收机制 垃圾回收机制的关键知识点 初步了解判断方法-引用计数法 GCRoot和可达性分析算法 什么是可达性分析算法 什么是GC Root 对象回收的关键知识点 标记对象可回收就一定会被回收吗&#xff1f; 可达性分析算…

使用R语言进行简单的因子分析

在本文中&#xff0c;将介绍如何使用R语言进行因子分析&#xff0c;并通过一个示例演示整个过程。因子分析是一种多元统计分析方法&#xff0c;用于探索变量之间的潜在结构和关系。R语言提供了丰富的统计工具和包&#xff0c;使因子分析的实现变得简单而高效。 准备工作 首先…

c++中的链表list的模拟实现

拖更了半个月&#xff0c;我终于来填c的坑啦。上次我们说的vetcor不知道小伙伴还记得多少呢&#xff1f;今天我们要讲list的模拟实现。 目录 架构结点list表的结构 构造函数尾插push_back()尾删pop_back()计算个数&#xff1a;size()判断空empty()※迭代器问题普通迭代器迭代器…
最新文章