美文网首页
Vue实现在线签名

Vue实现在线签名

作者: 安北分享 | 来源:发表于2021-06-21 19:04 被阅读0次

1.首先,安装 vue-esign

npm install vue-esign --save

2.首先,在main.js中引入

import vueEsign from 'vue-esign'
Vue.use(vueEsign)

3.在 组件 中写入

<template>
<div class="esign">
  <div class="esign-box">
      <vue-esign
        class="sign1"
        ref="esign"
        :width="800"
        :height="300"
        :isCrop="isCrop"
        :lineWidth="lineWidth"
        :lineColor="lineColor"
        :bgColor.sync="bgColor"
      />
    </div>
        <div class="esigh-btns">
    <button @click="handleReset">清空画板</button>
    <button @click="handleGenerate">确认</button>
     </div>
     <div class="esigh-result">
      <img v-if="resultImg" :src="resultImg" alt="" />
    </div>
  </div>
</template>
<script>

export default {
  data() {
    return {
      lineWidth: 6,
      lineColor: "#000000",
      bgColor: "",
      resultImg: "",
      isCrop: false,
      borders: "1px solid red",
    };
  },

  methods: {
    handleReset() {
      this.$refs.esign.reset();
    },
    handleGenerate() {
      this.$refs.esign
        .generate()
        .then((res) => {
          this.resultImg = res;
        })
        .catch((err) => {
          alert(err);
          // 画布没有签字时会执行这里 'Not Signned'
        });
    },
  },

}
</script>

<style scoped>
.esign {
  max-width: 1000px;
  margin: auto;
  padding: 10px;
  border: 1px solid rebeccapurple;
}
.esigh-btns button {
  color: #fff;
  height: 40px;
  width: 100px;
  font-size: 16px;
  margin-right: 10px;
  outline: none;
  border-radius: 4px;
  background: #f60;
  border: 1px solid transparent;
}
.esigh-btns button:active {
  color: #fff;
  box-shadow: 0px 0px 50px orangered inset;
}
.esigh-result {
  margin-top: 10px;
}
.esigh-result img {
  display: block;
  /* max-width: 100%; */
  /* height: auto; */
  max-width: 50%;
  height: 50%;
  margin: auto;
  left: 50%;
  transform: rotateX(50%);
  border: 1px solid #ececee;
}
.esignature {
  margin: 10px 0;
  border: 2px solid #ccc;
}
</style>

4.在父组件中使用即可

效果截图:

image

相关文章

  • Vue实现在线签名

    1.首先,安装 vue-esign 2.首先,在main.js中引入 3.在 组件 中写入 4.在父组件中使用即可...

  • 仿vue实现邮件在线签名生成器

    基于vue双向数据绑定的思想,实现一个在线邮件签名生成器。 直接上演示代码: 邮件...

  • pdf.js的使用实例

    最近 vue项目要在移动端实现在线浏览pdf,所以想到用pdf.jspdf.js可以实现在线预览pdf文档,核心部...

  • mui+vue实现图片上传

    mui+vue实现图片上传 在线工具:http://mxdqh.top/ /* ...

  • Vue页面预览PDF文件

    vue-pdf,可实现在线预览 PDF 格式的文档,流程: 在搭建好的 Vue 项目中,引入 Vue-pdf np...

  • vue 实现手写电子签名

    1.兼容 PC 和 Mobile; 2.画布自适应屏幕大小变化(窗口缩放、屏幕旋转时画布无需重置,自动校正坐标偏移...

  • Vue、Springboot实现接口签名

    1、实现思路   接口签名目的是为了,确保请求参数不会被篡改,请求的数据是否已超时,数据是否重复提交等。 客户端提...

  • vue(element)中使用monaco实现代码高亮

    vue(element)中使用monaco实现代码高亮 使用的是vue语言,用element的组件,要做一个在线编...

  • SpringBoot+Vue+WebSocket 实现在线聊天

    一、前言 本文将基于 SpringBoot + Vue + WebSocket 实现一个简单的在线聊天功能 页面如...

  • vue 电子签名

    最近公司要求用h5实现电子签名,在网上搜索后,发现一章文章很实用,用vue,canvas实现。 在移动端上需要在获...

网友评论

      本文标题:Vue实现在线签名

      本文链接:https://www.haomeiwen.com/subject/fnxsyltx.html