New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-sign-lim

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-sign-lim

## Getting Started

latest
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

react-sign-lim

Getting Started

Install dependencies,

$    npm install react-sign-lim --save
    // 或
$    pnpm install react-sign-lim --save
    // 或
$    yarn add react-sign-lim

组件使用

import React, { useState } from 'react';
import ReactSign from 'react-sign-lim';
import { Button, Space, Divider } from 'antd';
import 'antd/dist/antd.css';
console.log(ReactSign, Button);

function Index() {
  const $sign = React.createRef();
  const [imageSrc, setImageSrc] = useState();
  const reset = () => $sign.current.reset();
  const toImage = () => $sign.current.toImage().then((res) => setImageSrc(res));
  const toClip = () => $sign.current.clip().then((res) => setImageSrc(res));

  return (
    <div>
      <div style={{ border: '1px solid red', padding: '10px' }}>
        <ReactSign ref={$sign} lineWidth={6} height={300} width={800} bgColor={'#fff'} />
      </div>

      <Space style={{ margin: '20px 0' }}>
        <Button onClick={reset} type="primary" danger>
          重置
        </Button>
        <Button onClick={toImage} type="primary">
          转为图片
        </Button>
        <Button onClick={toClip}>截取</Button>
      </Space>

      {imageSrc && (
        <div>
          <Divider style={{ visibility: 'hidden' }} />
          <img src={imageSrc} alt="截图" />
        </div>
      )}
    </div>
  );
}

export default Index;

参数说明

组件 props 可传入参数如下:

参数名参数值说明默认值
widthnumber签字版宽度800
heightnumber签字版高度300
lineWidthnumber签字笔笔尖宽度4
lineColorstring签字笔颜色"#FF0"
bgColorstring签字版背景颜色""
qualitynumber导出签字图片质量1
requiredBoolen导出签名前是否校验有效书写false

组件暴露出的实例方法

  • toImage(),返回一个 Promise;参数是为图片 base64 字符串;
  • clip(),返回一个 Promise;参数是为图片 base64 字符串,同时会裁剪签字板,会尽可能截取签字的有效区域导出图片;
  • rest(),清空签字画板。

gitLab 地址

https://gitlab.com/react-component1/react-sign-lim.git

FAQs

Package last updated on 19 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts