uniapp中使用leaferui使用Canvas绘制复杂异形表格的实现方法

embedded/2025/3/1 22:09:06/

需求:

如下图,要实现左图的样式,先实现框架,文字到时候 往里填就行了,原来的解决方案是想用css,html来实现,发现实现起来蛮麻烦的。我也没找到合适的实现方法,最后换使用canvas来实现,使用的js库是leaferui

1.安装:用game是因为有一些交互,反正体积也不大

npm install leafer-game

2.wxml

    <canvas:style="'width:'+cabox.width+'px;height:'+cabox.height+'px;'"id="leafer"type="2d":width="cabox.width":height="cabox.height"catchtouchstart="receiveEvent"catchtouchmove="receiveEvent"catchtouchend="receiveEvent"catchtouchcancel="receiveEvent"></canvas>

3.javascript

  lf = new Leafer({view: window, width: that.cabox.width, height: that.cabox.height})lf.add(Rect.one(0,0,that.cabox.width,that.cabox.height));lf.add(Rect.one({width: that.cabox.width, height: that.cabox.height, strokeWidth: 2, stroke: "black",}));lf.add(Rect.one({strokeWidth: 2,stroke: "black",width: (that.cabox.perBox * 11.5),height: (that.cabox.perBox * 11.5),x: that.cabox.perBox * 1.75,y: that.cabox.perBox * 1.75}));lf.add(Rect.one({strokeWidth: 2,stroke: "black",width: (that.cabox.perBox * 9),height: (that.cabox.perBox * 9),x: that.cabox.perBox * 3,y: that.cabox.perBox * 3}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [0, 0, that.cabox.perBox * 3, that.cabox.perBox * 3]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [that.cabox.width, 0, that.cabox.perBox * 12, that.cabox.perBox * 3]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [that.cabox.width, that.cabox.height, that.cabox.perBox * 12, that.cabox.perBox * 12]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [0, that.cabox.height, that.cabox.perBox * 3, that.cabox.perBox * 12]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [that.cabox.perBox*6, 0, that.cabox.perBox*6, that.cabox.height]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [that.cabox.perBox*9, 0, that.cabox.perBox*9, that.cabox.height]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [0, that.cabox.perBox*6, that.cabox.width, that.cabox.perBox*6]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [0, that.cabox.perBox*9, that.cabox.width, that.cabox.perBox*9]}));


http://www.ppmy.cn/embedded/169159.html

相关文章

linux第四讲----基础开发工具vim

1.软件安装 这里以ubuntu为例&#xff0c;安装sl软件,输入这个命令即可自动安装~ 使用一下&#xff0c;输入sl&#xff0c;屏幕上会出现一个移动的小火车 之后不想要了准备卸载就输入&#xff1a; 注意&#xff1a;1&#xff09;下载软件时也可以进行搜索~ 2&#xff09;cento…

ElasticSearch核心技术解析:倒排索引与IK分词器如何解决中文搜索痛点

在传统数据库中&#xff0c;模糊查询往往难以应对现实中的复杂情况。随着数据量的增加&#xff0c;查询时间显著变慢&#xff0c;功能也相对单一。当搜索时出现错别字或拼音输入时&#xff0c;搜索结果往往不尽如人意。因此&#xff0c;我们需要学习一种强大的搜索框架技术——…

C#开发——日期操作类DateTime

在C#中&#xff0c;日期和时间的操作主要通过 System.DateTime 类来实现。 DateTime 提供了丰富的属性和法&#xff0c;用于处理日期和时间的创建、格式化、比较和计算等操作。以下是一些常用的日期函数和特性&#xff1a; 一、创建日期和时间 1、直接指定日期和时间&…

TCP长连接与短连接

TCP长连接与短连接 TCP&#xff08;传输控制协议&#xff09;中的长连接和短连接是两种不同的连接管理方式&#xff0c;各有优缺点&#xff1a; 短连接 短连接是指客户端与服务器完成一次数据交换后就断开连接。下次需要通信时&#xff0c;再重新建立连接。 特点&#xff1…

k8s环境搭建(从创建完一台虚拟机开始)

注意&#xff1a; 在这之前&#xff0c;所有主机需要关闭防火墙&#xff01;&#xff01;&#xff01; 1. docker 安装 所有主机都需要 1.1配置仓库 vim /etc/yum.repos.d/docker.repo https://mirror.tuna.tsinghua.edu.cn/docker-ce/linux/rhel/9/x86_64/stable/ 1.2 下…

RabbitMQ 集群部署方案

RabbitMQ 一、安装 RabbitMQ 二、更改配置文件 三、配置集群 四、测试 环境准备&#xff1a;三台服务器&#xff0c;系统是 CentOS7 IP地址分别是&#xff1a; rabbitmq1&#xff1a;192.168.152.71rabbitmq2&#xff1a;192.168.152.72rabbitmq3&#xff1a;192.168.152.…

三个小时学完vue3(一)

Vue3 之前就学过一些&#xff0c;不过用的比较少&#xff0c;基本忘完了/(ㄒoㄒ)/~~ 跟着B站视频迅速回忆一下 创建一个Vue 3 应用 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport&…

【PyCharm安装】【Python安装】【PyCharm使用】全流程

2025 - 02 - 28 - 第 64 篇 Author: 郑龙浩 / 仟濹 【PyCharm安装】【Python安装】【PyCharm使用】 文章目录 Python安装PyCharm安装及使用一 Python安装1 **Python 安装包里都包括什么呢&#xff1f;&#xff1f;&#xff1f;**2 安装时的一些选项勾选有何作用&#xff1f;(1…