【sgExcelGrid】自定义组件:简单模拟Excel表格拖拽、选中单元格、横行、纵列、拖拽圈选等操作

特性:

  1. 可以自定义拖拽过表格
  2. 可以点击某个表格,拖拽右下角小正方形进行任意方向选取单元格
  3. 支持选中某一行、列
  4. 支持监听@selectedGrids、@selectedDatas事件获取选中项的DOM对象和数据数组
  5. 支持props自定义显示label字段别名

 sgExcelGrid源码

<template><div :class="$options.name"><div class="ruler-corner"></div><div class="horizontal-ruler" :style="{ left: `${-rulerPosition.x}px` }"><divclass="tick":hoverGrid="hoverGrid.x === A_Z[i]"@click="(hoverGrid = { x: A_Z[i] }), (mousedownGrid = {})"v-for="(a, i) in A_Z.slice(0, colCount_)":key="i">{{ a }}</div></div><div class="vertical-ruler" :style="{ top: `${-rulerPosition.y}px` }"><divclass="tick":hoverGrid="hoverGrid.y === i"@click="(hoverGrid = { y: i }), (mousedownGrid = {})"v-for="(a, i) in Math.ceil(pageSize / colCount_)":key="i">{{ i + 1 }}</div></div><div class="grids-scroll" ref="scrollContainer"><div class="grids" ref="dragContainer" :selectedGrids="selectedGrids.length > 0"><divclass="grid":hoverGridX="selectedGrids.length == 0 && hoverGrid.x === gridsData[i].x":hoverGridY="selectedGrids.length == 0 && hoverGrid.y === gridsData[i].y":mousedownGrid="mousedownGrid.x === gridsData[i].x && mousedownGrid.y === gridsData[i].y":dragMove="isMouseDragMove":type="a.strong ? 'primary' : ''"v-for="(a, i) in data":key="i"@mouseover="hoverGrid = gridsData[i]"@mouseout="hoverGrid = {}"@click="clickGrid(i)"><span :title="a[label]">{{ a[label] }}</span><i class="el-icon-close" @click="del(a)" /><divclass="position-text":title="`点击复制`"@click="$g.copy($g.stripHTML(getPositionText(gridsData[i])), true)"v-html="getPositionText(gridsData[i])"></div><div class="drag-select-btn" @mousedown.stop="clickResizeHandle"></div></div></div></div><!-- 拖拽 --><sgDragMoveTile :data="dragMoveTileData" @scroll="scroll" /></div>
</template>
<script>
import sgDragMoveTile from "@/vue/components/admin/sgDragMoveTile";
export default {name: "sgExcelGrid",components: {sgDragMoveTile,},data() {return {A_Z: [...Array(26)].map((v, i) => String.fromCharCode(i + 65)),hoverGrid: {}, //移入的宫格标记mousedownGrid: {}, //点击的宫格标记gridsData: [], //记录网格宫格状态selectedGrids: [], //被选中的网格宫格DOMselectedDatas: [], //被选中的网格宫格数据rulerPosition: { x: 0, y: 0 },dragMoveTileData: {},gridWidth: 200,gridHeight: 100,colCount_: 8,pageSize_: 100,isMouseDragMove: false, //鼠标拖拽选中移动label: `label`, //显示文本字段名};},props: ["value","props","data","pageSize", //每页显示多少个宫格"colCount", //列数],computed: {},watch: {props: {handler(newValue, oldValue) {if (newValue && Object.keys(newValue).length) {newValue.label && (this.label = newValue.label);}},deep: true, //深度监听immediate: true, //立即执行},pageSize: {handler(newValue, oldValue) {//console.log('深度监听:', newValue, oldValue);newValue && (this.pageSize_ = newValue);},deep: true, //深度监听immediate: true, //立即执行},data: {handler(newValue, oldValue) {this.init_gridsData();},deep: true, //深度监听immediate: true, //立即执行},colCount: {handler(newValue, oldValue) {//console.log('深度监听:', newValue, oldValue);newValue && (this.colCount_ = newValue);this.$nextTick(() => {this.$el.style.setProperty("--gridWidth", `${this.gridWidth}px`); //js往css传递局部参数this.$el.style.setProperty("--gridHeight", `${this.gridHeight}px`); //js往css传递局部参数this.$el.style.setProperty("--gridsWidth",`${this.colCount_ * this.gridWidth}px`); //js往css传递局部参数});},deep: true, //深度监听immediate: true, //立即执行},selectedGrids: {handler(newValue, oldValue) {this.$emit(`selectedGrids`, newValue || []);},deep: true, //深度监听// immediate: true, //立即执行},selectedDatas: {handler(newValue, oldValue) {this.$emit(`selectedDatas`, newValue || []);},deep: true, //深度监听// immediate: true, //立即执行},},created() {},mounted() {this.init_grid_view();this.addEvents();},destroyed() {this.removeEvents();},methods: {clickGrid(i) {(this.mousedownGrid = this.gridsData[i]),(this.hoverGrid = {}),this.resetSelectGrid();this.selectedGrids = [this.gridsData[i]];this.selectedDatas = [this.data[i]];},clickResizeHandle(e) {this.originRect = e.target.parentNode.getBoundingClientRect();this.originRect.bottomRightX = this.originRect.x + this.originRect.width; //右下角坐标.xthis.originRect.bottomRightY = this.originRect.y + this.originRect.height; //右下角坐标.ythis.__addWindowEvents();},__addWindowEvents() {this.__removeWindowEvents();addEventListener("mousemove", this.mousemove_window);addEventListener("mouseup", this.mouseup_window);},__removeWindowEvents() {removeEventListener("mousemove", this.mousemove_window);removeEventListener("mouseup", this.mouseup_window);},mousemove_window(e) {this.isMouseDragMove = true;let { x, y } = e;let minWidth = 0,minHeight = 0,maxWidth = innerWidth,maxHeight = innerHeight;x < 0 && (x = 0),y < 0 && (y = 0),x > maxWidth && (x = maxWidth),y > maxHeight && (y = maxHeight);let style = {};style.x = this.originRect.x;style.y = this.originRect.y;style.width = x - this.originRect.x;style.width <= minWidth &&((style.width = Math.abs(style.width)),((style.x = this.originRect.x - style.width),(style.width = style.width + this.originRect.width)));style.height = y - this.originRect.y;style.height <= minHeight &&((style.height = Math.abs(style.height)),((style.y = this.originRect.y - style.height),(style.height = style.height + this.originRect.height)));style.width > maxWidth && (style.width = maxWidth);style.height > maxHeight && (style.height = maxHeight);this.calcRectGrid(style);},mouseup_window(e) {this.isMouseDragMove = false;this.__removeWindowEvents();},resetAllGridStatus() {this.resetSelectGrid();this.mousedownGrid = {};},resetSelectGrid(d) {this.selectedGrids = [];this.selectedDatas = [];let grids = this.$refs.dragContainer.querySelectorAll(`.grid`);grids.forEach((v) => {v.removeAttribute("selected-left");v.removeAttribute("selected-top");v.removeAttribute("selected-right");v.removeAttribute("selected-bottom");v.removeAttribute("selected");});},// 计算是否选中格子calcRectGrid(rect) {this.resetSelectGrid();this.selectedGrids = this.getSelectedDoms({targetDoms: this.$refs.dragContainer.querySelectorAll(`.grid`),rect,});this.selectedGrids.forEach((grid) => {let grid_rect = grid.getBoundingClientRect();let gridRectScreenWidth = grid_rect.x + grid_rect.width;let gridRectScreenHeight = grid_rect.y + grid_rect.height;grid_rect.x <= rect.x &&rect.x < gridRectScreenWidth &&grid.setAttribute("selected-left", true);grid_rect.y <= rect.y &&rect.y < gridRectScreenHeight &&grid.setAttribute("selected-top", true);let rectScreenWidth = rect.x + rect.width;let rectScreenHeight = rect.y + rect.height;grid_rect.x < rectScreenWidth &&rectScreenWidth <= grid_rect.x + grid_rect.width &&grid.setAttribute("selected-right", true);grid_rect.y < rectScreenHeight &&rectScreenHeight <= grid_rect.y + grid_rect.height &&grid.setAttribute("selected-bottom", true);grid.setAttribute("selected", true);});},// 获取被选中的DOMgetSelectedDoms({ targetDoms, rect } = {}) {this.selectedDatas = [];return [...targetDoms].filter((targetDom, i) => {if (this.$g.isCrash(targetDom, rect)) {this.selectedDatas.push(this.data[i]);return targetDom;}}); // 获取被圈选的内容},// ----------------------------------------del(d) {this.$emit(`del`, d);},addEvents(d) {this.removeEvents();this.__removeWindowEvents();addEventListener("resize", this.resize);},removeEvents(d) {removeEventListener("resize", this.resize);},getPositionText(gridData) {return `<span>第${gridData.y + 1}行</span>&nbsp;<span>第${gridData.x}列</span>`;},init_grid_view() {this.resize();this.$nextTick(() => {this.init_sgDragMoveTile();});},init_gridsData(d) {this.gridsData = [...Array(this.pageSize_)].map((v, i) => ({x: this.A_Z[i % this.colCount_],y: Math.floor(i / this.colCount_),}));this.$nextTick(() => {this.resetAllGridStatus();});},init_sgDragMoveTile() {this.dragMoveTileData = {scrollContainer: this.$refs.scrollContainer,dragContainer: this.$refs.dragContainer,};},resize(d) {this.rulerPosition = {x: 0,y: 0,};},scroll(e) {this.rulerPosition = {x: e.target.scrollLeft,y: e.target.scrollTop,};},},
};
</script>
<style lang="scss" scoped>
.sgExcelGrid {/*禁止选中文本*/user-select: none;overflow: hidden;$tickDis: 40px;$gridWidth: var(--gridWidth);$gridHeight: var(--gridHeight);$gridsWidth: var(--gridsWidth);$scrollbarWidth: 14px;width: 100%;height: 100%;position: relative;.ruler-corner {position: absolute;z-index: 2;left: 0;top: 0;width: $tickDis;height: $tickDis;box-sizing: border-box;border: 1px solid #ebeef5;border-right: none;border-bottom: none;background-color: #eff2f755;/*遮罩模糊*/backdrop-filter: blur(5px);}.horizontal-ruler {position: absolute;z-index: 1;left: 0;top: 0;margin-left: $tickDis;display: flex;flex-wrap: nowrap;border-top: 1px solid #ebeef5;border-left: 1px solid #ebeef5;/*遮罩模糊*/backdrop-filter: blur(5px);// box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);.tick {display: flex;justify-content: center;align-items: center;flex-shrink: 0;width: $gridWidth;height: $tickDis;box-sizing: border-box;border-top: 1px solid transparent;border-left: 1px solid transparent;border-bottom: 1px solid #ebeef5;border-right: 1px solid #ebeef5;font-family: DIN-Black;background-color: #eff2f755;&[hoverGrid] {border-left: 1px solid #409eff;border-right: 1px solid #409eff;background-color: #b3d8ff99;color: #409eff;}}}.vertical-ruler {position: absolute;z-index: 1;left: 0;top: 0;margin-top: $tickDis;display: flex;flex-wrap: wrap;flex-direction: column;border-top: 1px solid #ebeef5;border-left: 1px solid #ebeef5;/*遮罩模糊*/backdrop-filter: blur(5px);// box-shadow: 2px 0 12px 0 rgba(0, 0, 0, 0.1);.tick {display: flex;justify-content: center;align-items: center;flex-shrink: 0;width: $tickDis;height: $gridHeight;box-sizing: border-box;border-top: 1px solid transparent;border-left: 1px solid transparent;border-bottom: 1px solid #ebeef5;border-right: 1px solid #ebeef5;font-family: DIN-Black;background-color: #eff2f7;background-color: #eff2f755;&[hoverGrid] {border-top: 1px solid #409eff;border-bottom: 1px solid #409eff;background-color: #b3d8ff99;color: #409eff;}}}.grids-scroll {width: calc(100% - #{$tickDis});height: calc(100vh - 310px);box-sizing: border-box;overflow: auto;position: relative;margin: $tickDis 0 0 $tickDis;.grids {width: calc(#{$gridsWidth} + #{$scrollbarWidth});min-height: calc(#{$gridHeight} + #{$scrollbarWidth});overflow: auto;display: flex;flex-wrap: wrap;align-content: flex-start;box-sizing: border-box;border-top: 1px solid #ebeef5;border-left: 1px solid #ebeef5;.grid {display: flex;justify-content: center;align-items: center;width: $gridWidth;height: $gridHeight;padding: 20px;box-sizing: border-box;border-top: 1px solid transparent;border-left: 1px solid transparent;border-bottom: 1px solid #ebeef5;border-right: 1px solid #ebeef5;word-wrap: break-word;word-break: break-all;white-space: break-spaces;position: relative;span {/*多行省略号*/overflow: hidden;word-break: break-all;white-space: break-spaces;display: -webkit-box;-webkit-box-orient: vertical;max-height: min-content;-webkit-line-clamp: 3;line-height: 1.2;}// 坐标文本.position-text {position: absolute;height: 22px;z-index: 1;left: 0px;top: 0px;display: none;flex-wrap: nowrap;white-space: nowrap;align-items: center;color: white;background-color: #00000055;box-sizing: border-box;padding: 0 5px;border-radius: 0 0 8px 0;>>> span {font-size: 12px !important;}cursor: cell;&:hover {background-color: #409eff;color: white;}}// 删除i.el-icon-close {z-index: 1;display: none;position: absolute;right: 0;top: 0;font-size: 12px !important;justify-content: center;align-items: center;color: white;background-color: #409eff;box-sizing: border-box;padding: 5px;border-radius: 0 0 0 8px;cursor: pointer;&:hover {background-color: #f56c6c;}}// 拖拽选区.drag-select-btn {position: absolute;height: 9px;width: 9px;z-index: 1;right: -4.5px;bottom: -4.5px;display: none;box-sizing: border-box;border: 2px solid white;background-color: #f56c6c;cursor: crosshair;}&:nth-of-type(2n) {background-color: #eff2f755;}&[hoverGridX] {border-left: 1px solid #409eff;border-right: 1px solid #409eff;background-color: #f2f8fe;}&[hoverGridY] {border-top: 1px solid #409eff;border-bottom: 1px solid #409eff;background-color: #f2f8fe;}&[mousedownGrid] {border: 1px solid #f56c6c;background-color: #f56c6c22;.drag-select-btn {display: block;}}&[selected] {// border: 1px solid #f56c6c;border-top: 1px solid transparent;border-left: 1px solid transparent;border-right: 1px solid #f56c6c22;border-bottom: 1px solid #f56c6c22;background-color: #f56c6c22;.position-text {background-color: #f56c6c66;color: white;&:hover {background-color: #f56c6c;}}i.el-icon-close {background-color: #f56c6c66;&:hover {background-color: #f56c6c;}}.drag-select-btn {display: none;}&:hover:not([dragMove]) {border: 1px solid #f56c6c;background-color: #f56c6c66 !important;}}&[selected-left] {border-left: 1px solid #f56c6c;}&[selected-top] {border-top: 1px solid #f56c6c;}&[selected-right] {border-right: 1px solid #f56c6c;}&[selected-bottom] {border-bottom: 1px solid #f56c6c;}&[mousedownGridX] {border-left: 1px solid #f56c6c;border-right: 1px solid #f56c6c;background-color: #f56c6c22;}&[mousedownGridY] {border-top: 1px solid #f56c6c;border-bottom: 1px solid #f56c6c;background-color: #f56c6c22;}&[dragMove] {}&:hover:not([mousedownGrid]):not([dragMove]) {background-color: #b3d8ff99;i,.position-text {display: flex;}}}&[selectedGrids] {.grid {&:hover:not([mousedownGrid]):not([dragMove]):not([selected]) {border: 1px solid #409eff;}}}}}
}
</style>

应用

<template><sgExcelGrid:props="{ label: `MC` }":data="gridDatas":pageSize="pageSize"@del="delGrid"@selectedDatas="selectedDatas"/>
</template>
<script>
import sgExcelGrid from "@/vue/components/admin/sgExcelGrid";
export default {components: {sgExcelGrid,},data() {return {gridDatas: [{ ID: 1, value: 1, MC: "显示文本1" },{ ID: 2, value: 2, MC: "显示文本2" },{ ID: 3, value: 3, MC: "显示文本3" },{ ID: 4, value: 4, MC: "显示文本4" },{ ID: 5, value: 5, MC: "显示文本5" },],pageSize: 100, //每页显示多少个单元格rectSelectIDS: [], //选中的ID数组};},props: ["value"],computed: {},watch: {},created() {},mounted() {},destroyed() {},methods: {selectedDatas(d) {this.rectSelectIDS = d.map((v) => v.ID); //获取选中项ID数组},delGrid(d) {//删除单元格},},
};
</script>

基于【sgDragMoveTile】自定义组件:拖拽瓦片图、地图、大图,滚动条对应同步滚动_用鼠标拖拽(drag)内容div”,滚动条对应同步滚动 vue-CSDN博客文章浏览阅读140次。【代码】【sgDragMoveTile】自定义组件:拖拽瓦片图、地图、大图,滚动条对应同步滚动。_用鼠标拖拽(drag)内容div”,滚动条对应同步滚动 vuehttps://blog.csdn.net/qq_37860634/article/details/133292981

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

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

相关文章

java-ssm-jsp基于ssm的冰淇淋在线购买网站

java-ssm-jsp基于ssm的冰淇淋在线购买网站 获取源码——》公主号&#xff1a;计算机专业毕设大全

了解 HTTPS 中间人攻击:保护你的网络安全

&#x1f90d; 前端开发工程师、技术日更博主、已过CET6 &#x1f368; 阿珊和她的猫_CSDN博客专家、23年度博客之星前端领域TOP1 &#x1f560; 牛客高级专题作者、打造专栏《前端面试必备》 、《2024面试高频手撕题》 &#x1f35a; 蓝桥云课签约作者、上架课程《Vue.js 和 E…

C++单例模式、工厂模式

一、单例模式 (一) 什么是单例模式 1. 是什么&#xff1f; 在系统的整个生命周期内&#xff0c;一个类只允许存在一个实例。 2. 为什么&#xff1f; 两个原因&#xff1a; 节省资源。方便控制&#xff0c;在操作公共资源的场景时&#xff0c;避免了多个对象引起的复杂操作…

10 | MySQL为什么有时候会选错索引?

前面我们介绍过索引&#xff0c;你已经知道了在 MySQL 中一张表其实是可以支持多个索引的。但是&#xff0c;你写 SQL 语句的时候&#xff0c;并没有主动指定使用哪个索引。也就是说&#xff0c;使用哪个索引是由 MySQL 来确定的。 不知道你有没有碰到过这种情况&#xff0c;一…

ODI报错

三月 08, 2024 1:20:09 下午 oracle.odi.mapping 信息: Start generation of map physical design: MapPhysicalDesign New_Mapping.物理 三月 08, 2024 1:20:09 下午 oracle.odi.mapping 信息: Finished generation of map physical design: MapPhysicalDesign New_Mapping.物…

Axure基础 各元件的作用及介绍

图像热区 增加按钮或者文本的点击区域&#xff0c;他是透明的&#xff0c;在预览时看不见。 动态面板 用来绘制一下带交互效果的元件&#xff0c;他是动态的&#xff0c;如轮播图&#xff0c;一个动态面板里可以有多个子面板&#xff0c;每一个子面板对应着不同的效果。 他…

HarmonyOS NEXT应用开发之MpChart图表实现案例

介绍 MpChart是一个包含各种类型图表的图表库&#xff0c;主要用于业务数据汇总&#xff0c;例如销售数据走势图&#xff0c;股价走势图等场景中使用&#xff0c;方便开发者快速实现图表UI。本示例主要介绍如何使用三方库MpChart实现柱状图UI效果。如堆叠数据类型显示&#xf…

前端框架的发展历史介绍

前端框架的发展历史是Web技术进步的一个重要方面。从最初的简单HTML页面到现在的复杂单页应用程序&#xff08;SPA&#xff09;&#xff0c;前端框架和库的发展极大地推动了Web应用程序的构建方式。以下是一些关键的前端框架和库&#xff0c;以及它们的发布年份、创建者和主要特…

Open-Sora:开源 Sora 复现方案,成本降低 46%

Colossal-AI 开源了完整的 Sora 复现架构方案 Open-Sora&#xff0c;声称可降低 46% 复现成本&#xff0c;并将模型训练输入序列长度扩充至 819K patches。 演示站点&#xff1a; https://ai.uaai.cn UAAI 官方论坛&#xff1a; www.jingyuai.com京娱AI Sora 算法复现方案 在 …

unity学习(53)——选择角色界面--分配服务器返回的信息

好久没写客户端了&#xff0c;一上手还不太适应 1.经过测试&#xff0c;成功登陆后&#xff0c;客户端请求list_request&#xff0c;成功返回&#xff0c;如下图&#xff1a; 可见此时model第三个位置的参数是1.也成功返回了所有已注册角色的信息。 2.之前已知创建的角色信息…

复习C的内存管理

来自&#xff1a;漫谈C语言内存管理_c语言内存管理机制-CSDN博客 C语言是音视频开发所必须的。 变量是一段连续内存空间的别名。变量的类型是固定内存大小的别名。但是类型不是只确定了变量内存大小&#xff0c;还确定了变量是小数、整数还是字符。 linux32下的C的内存模型&…

视频远程监控平台EasyCVR集成后播放只有一帧画面的原因排查与解决

智慧安防视频监控平台EasyCVR能在复杂的网络环境中&#xff08;专网、局域网、广域网、VPN、公网等&#xff09;将前端海量的设备进行统一集中接入与视频汇聚管理&#xff0c;平台可支持的接入协议包括&#xff1a;国标GB28181、RTSP/Onvif、RTMP&#xff0c;以及厂家的私有协议…

Java中常用的集合及方法(2)

在Java&#xff08;JDK8&#xff09;中&#xff0c;集合&#xff08;Collection&#xff09;是数据结构的实现&#xff0c;用于存储和操作对象集合。 集合&#xff08;Collection&#xff09;中包含的一般类或接口&#xff1a; 在这其中呢&#xff0c;我们经常使用的其实就是L…

多边形质心(centroid)的计算方法

原文代码 // polygon按顺时针排列顶点 function getCentroid(polygon) {var totalArea 0var totalX 0var totalY 0var points polygon[0]for (var i 0; i < points.length; i) {// a、b以及原点构成一个三角形var a points[i 1]var b points[i]var area 0.5 * (a[…

Django模型层(附带test环境)

Django模型层(附带test环境) 目录 Django模型层(附带test环境)连接数据库Django ORM在models.py中建表允许为空指定默认值数据库迁移命令 开启测试环境建表语句补充(更改默认表名)数据的增加时间数据的时区 多表数据的增加一对多多对多 数据的删除修改数据查询数据查询所有数据…

【BUG】Windows状态栏总卡死解决办法

屋漏偏逢连夜雨&#xff0c;正在赶deadline呢&#xff0c;Windows状态老卡死&#xff0c;一时间崩溃。 解决办法&#xff1a; 右键状态栏新闻和咨询关掉 这个烧笔新闻与资讯我真服了

哈希表应用

例题 在这里使用一个简化版的问题进行分析&#xff1a;给定N个自然数&#xff0c;值域是&#xff0c;求出这N个自然数中共有多少个不同的自然数。 分析 如果值域是&#xff0c;那么可以利用之前介绍过的计数排序算法解决问题。定义一个的大数组a&#xff0c;每个位置a[x]所对…

6. Gin集成redis

文章目录 一&#xff1a;连接Redis二&#xff1a;基本使用三&#xff1a;字符串四&#xff1a;列表五&#xff1a;哈希六&#xff1a;Set七&#xff1a;管道八、事务九&#xff1a;示例 代码地址&#xff1a;https://gitee.com/lymgoforIT/golang-trick/tree/master/14-go-redi…

lvs集群中NAT模式

群集的含义 由多台主机构成&#xff0c;但对外表现为一个整体&#xff0c;只提供一个访问入口&#xff0c;相当于一台大型的计算机。 横向发展:放更多的服务器&#xff0c;有调度分配的问题。 垂直发展&#xff1a;升级单机的硬件设备&#xff0c;提高单个服务器自身功能。 …

贪吃蛇(C语言实现)

贪食蛇&#xff08;也叫贪吃蛇&#xff09;是一款经典的小游戏。 —————————————————————— 本博客实现使用C语言在Windows环境的控制台中模拟实现贪吃蛇小游戏。 实行的基本功能&#xff1a; • 贪吃蛇地图的绘制 • 蛇吃食物的功能&#xff08;上、…