@eve-sama/ngx-signature-pad

中文文档
16.0.0发布于 2023/05/20TypeScriptES Module近 30 天下载 6841
中文使用文档
文档目录10 节
  1. 导言
  2. 演示
  3. 方向
  4. 安装
  5. 使用量
  6. 应用程序
  7. 应用程序
  8. Ngx 签名选项
  9. 实例方法
  10. 运行时修改配置

页:1 简体中文

导言

适合角生态的手写签名插件 suppprt V15.

avatar

演示

您可以看到 API 的所有详细方向并演示 这里。在 PC 和 Mobile 模式下有模糊的内容。 PC强调文档,Mobile强调实例.

方向

此工程基于画布插件 签名( p),而画布插件仅具有基本功能,例如 signature canvas我把它封了起来,它有以下特征:

  • 为 Angular 提供 API 更合适的样式 .
  • 提供本地插件中没有的特性, 如 modify state of signature manually, (中文)revert painting, (中文)fullScreen to sign 诸如来.
  • 您可以在运行时间更改配置, 如宽度/ 高度 .

安装

国家预防机制

npm install --save @eve-sama/ngx-signature-pad

线条

yarn add --save @eve-sama/ngx-signature-pad

使用量

应用程序

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

import { NgxSignaturePadModule } from '@eve-sama/ngx-signature-pad';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    // You need to import module of ngx-signature-pad
    NgxSignaturePadModule
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

应用程序

<ngx-signature-pad
  #signature
  [options]="options"
  (beginSign)="onBeginSign()"
  (endSign)="onEndSign()">
</ngx-signature-pad>
import { Component, ViewChild } from '@angular/core';
import { NgxSignaturePadComponent, NgxSignatureOptions } from '@eve-sama/ngx-signature-pad';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})
export class AppComponent {
  /** Catch object, call functions via instance object */
  @ViewChild('signature') signature: NgxSignaturePadComponent;

  /** You can see more introduction in the below about NgxSignatureOptions */
  public options: NgxSignatureOptions = {
    backgroundColor: '#F4F5F5',
    width: 570,
    height: 300,
    css: {
      'border-radius': '16px'
    }
  };

  /** The begin event of sign */
  onBeginSign(): void { }

  /** The end event of sign */
  onEndSign(): void { }
}

Ngx 签名选项

参数方向类型默认
dotSize单点半径.number | (() => number)- 说吧
minWidth一行最小宽度 .number0.5
maxWidth线的最大宽度 .number2.5
throttle每x毫秒绘制下个点最多一次。 把它设为0以关闭节奏.number16
minDistance仅在上一个比x像素更远时添加下个点.number0.5
backgroundColor用于清除背景的颜色 。 可以是上下文接受的任何颜色格式 。 满斯德. 如想将签名保存为JPEG图像,则使用"rgb(255,255,255)"(opaque white)等不透明的颜色.string'rgba(0,0,0,0)'
penColor画行用色相. 可以是上下文接受的任何颜色格式 。 满斯德.string'black'
velocityFilterWeight重量用于根据上一个速度来修改新的速度.number0.7
width画布的宽度.number300px
height画布的高度.number150px
css自定义css of canvs,您可以看到演示代码以获取细节信息. 注意我们使用 Renderer2 生成 cs, 不确定它是否支持所有 css{ [key: string]: string }- 说吧

实例方法

行为方向
toDataURL()作为 PNG 获取其数据 URL .
toDataURL("image/jpeg")作为 JPEG 获取其数据 URL .
toDataURL("image/svg+xml")作为 SVG 获取其数据 URL .
fromDataURL(dataUrl: string)从数据 URL 绘制签名图像, 您需要通过它 base64。 。 。 .
toData()返回签名图像为 IPointGroup[]。 。 。 .
fromData(pointGroups: IPointGroup[])绘制签名图像从 IPointGroup[]。 。 。 .
clear()清理画布.
isEmpty()如果画布是空的, 返回真实, 否则返回虚假 .
setDirty()那就把垫子的状态弄脏了 isEmpty() 返回虚假.
setEmpty()设置垫的状态为空, 那么 isEmpty() 返回真实.
revert()撤销最后的动作 。 请注意,如果您有更改 fullScreen() 财务报告和审定财务报表 miniScreen(),则 revert() 更改模式后无法工作。 在这种情况下,我不建议使用它.
fullScreen()可以将模式更改为 fullScreen,fullScreen 签名的宽比与midScreen 签名相同.
miniScreen()可以将模式更改为迷你Screen. 输入组件时,官方模式是迷你Screen.
getContext()拿帆布来 Context这是关于画布,在得到 Context,你可以做任何你想做的事,例如你可以使用 drawImage 在帆布板上绘制一些东西,请在 PC 中看到演示 dragImage。 。 。 .

运行时修改配置

此插件允许您在运行期间修改配置, 只要修改您想要通过的选项 。 注意您不仅可以更改选项的属性 。 因为 OnChanges 在这种情况下不会触发。 您需要重新指定选项 。 例如,初步备选方案如下:

const options: NgxSignatureOptions = {
  penColor: 'rgb(0, 0, 0)', // Black
  width: 300,
  height: 150
};

运行后代码,如果您想要更改笔的颜色,如果您将代码写入下面,则无效.

options.penColor = 'rgb(255, 0, 0)'; // Does not work, because can not trigger OnChanges

你需要重新分配如下.

const options: NgxSignatureOptions = {
  penColor: 'rgb(255, 0, 0)' // Change the black to red
  width: 300,
  height: 150
};

版本与发布记录

@eve-sama/ngx-signature-pad 共发布 27 个版本,首次发布于 2020/09/02;过去 12 个月发布了 0 个版本。

版本发布日期距今
16.0.0latest2023/05/203 年前
15.0.42022/11/293 年前
15.0.32022/11/293 年前
15.0.22022/11/293 年前
15.0.12022/11/293 年前
15.0.02022/11/293 年前

关于 @eve-sama/ngx-signature-pad 的常见问题

@eve-sama/ngx-signature-pad 是什么?

页:1 简体中文

如何安装 @eve-sama/ngx-signature-pad?

在项目目录运行 npm install @eve-sama/ngx-signature-pad,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@angular/cdk(^16.0.0)、@angular/common(^16.0.2)、@angular/core(^16.0.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@eve-sama/ngx-signature-pad 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@eve-sama/ngx-signature-pad 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@eve-sama/ngx-signature-pad 可以商用吗?

@eve-sama/ngx-signature-pad 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@eve-sama/ngx-signature-pad 的下载量有多少?

根据 npm 官方下载统计,@eve-sama/ngx-signature-pad 在 2026/10/14 – 2026/11/12 这 30 天内被下载 6,841 次,日均约 228 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@eve-sama/ngx-signature-pad 还在维护吗?

最新版本 16.0.0 发布于 2023/05/20(3 年前);至今共发布 27 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/09/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。