欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue使用smooth-signature實(shí)現(xiàn)移動(dòng)端橫豎屏電子簽字

 更新時(shí)間:2023年10月27日 10:08:24   作者:菜鳥(niǎo)書生  
這篇文章主要為大家介紹了vue使用smooth-signature實(shí)現(xiàn)移動(dòng)端橫豎屏電子簽字示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

vue使用smooth-signature實(shí)現(xiàn)移動(dòng)端電子簽字,包括橫豎屏

使用smooth-signature

npm install --save smooth-signature

頁(yè)面引入插件

import SmoothSignature from "smooth-signature";

實(shí)現(xiàn)效果

完整代碼

<template>
  <div class="sign-finish">
    <div class="wrap1" v-show="showFull">
      <span class="sign-title">請(qǐng)?jiān)趨^(qū)域內(nèi)簽字</span>
      <canvas class="canvas1" ref="canvas1" />
      <div class="actions">
          <button class="danger" @click="handleClear1" >清除</button>
          <button class="warning" @click="handleUndo1" >撤銷</button>
          <button class="primary" @click="handleFull" >橫屏</button>
          <button class="success" @click="handlePreview1" >保存</button>
      </div>
    </div>
    <div class="wrap2" v-show="!showFull">
      <div class="actionsWrap">
        <div class="actions">
          <button class="danger" @click="handleClear1" >清除</button>
          <button class="warning" @click="handleUndo1" >撤銷</button>
          <button class="primary" @click="handleFull" >豎屏</button>
          <button class="success" @click="handlePreview1" >保存</button>
        </div>
      </div>
      <canvas class="canvas" ref="canvas2" />
    </div>
  </div>
</template>

<script>
import SmoothSignature from "smooth-signature";
export default {
  name: "mbDemo",
  data() {
    return {
      showFull: true,
    };
  },
  mounted() {
    this.initSignature1();
    this.initSignture2();
  },
  methods: {
    initSignature1() {
      const canvas = this.$refs["canvas1"];
      const options = {
        width: window.innerWidth - 30,
        height: 200,
        minWidth: 2,
        maxWidth: 6,
        openSmooth:true,
        // color: "#1890ff",
        bgColor: '#f6f6f6',
      };
      this.signature1 = new SmoothSignature(canvas, options);
    },
    initSignture2() {
      const canvas = this.$refs["canvas2"];
      const options = {
        width: window.innerWidth - 120,
        height: window.innerHeight - 80,
        minWidth: 3,
        maxWidth: 10,
        openSmooth:true,
        // color: "#1890ff",
        bgColor: '#f6f6f6',
      };
      this.signature2 = new SmoothSignature(canvas, options);
    },
    handleClear1() {
      this.signature1.clear();
    },
    handleClear2() {
      this.signature2.clear();
    },
    handleUndo1() {
      this.signature1.undo();
    },
    handleUndo2() {
      this.signature2.undo();
    },
    handleFull() {
      this.showFull = !this.showFull;
    },
    handlePreview1() {
      const isEmpty = this.signature1.isEmpty();
      if (isEmpty) {
        alert("isEmpty");
        return;
      }
      const pngUrl = this.signature1.getPNG();
      console.log(pngUrl);
      // window.previewImage(pngUrl);
    },
    handlePreview2() {
      const isEmpty = this.signature2.isEmpty();
      if (isEmpty) {
        alert("isEmpty");
        return;
      }
      const canvas = this.signature2.getRotateCanvas(-90);
      const pngUrl = canvas.toDataURL();
      console.log('pngUrl',pngUrl);
      // window.previewImage(pngUrl, 90);
    },
  },
};
</script>

<style lang="less">
.sign-finish {
  height: 100vh;
  width: 100vw;
  button {
    height: 32px;
    padding: 0 8px;
    font-size: 12px;
    border-radius: 2px;
  }
  .danger {
    color: #fff;
    background: #ee0a24;
    border: 1px solid #ee0a24;
  }
  .warning {
    color: #fff;
    background: #ff976a;
    border: 1px solid #ff976a;
  }
  .primary {
    color: #fff;
    background: #1989fa;
    border: 1px solid #1989fa;
  }
  .success {
    color: #fff;
    background: #07c160;
    border: 1px solid #07c160;
  }
  canvas {
    border-radius: 10px;
    border: 2px dashed #ccc;
    
  }
  .wrap1 {
    height: 100%;
    width: 96%;
    margin: auto;
    margin-top: 100px;
    .actions {
      display: flex;
      justify-content: space-around;
    }
  }
  .wrap2 {
    padding: 15px;
    height: 100%;
    display: flex;
    justify-content: center;
    .actionsWrap {
      width: 50px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .canvas {
      flex: 1;
    }
    .actions {
      margin-right: 10px;
      white-space: nowrap;
      transform: rotate(90deg);
      button{
          margin-right: 20px;
      }
    }
  }
}
</style>

參考 https://github.com/linjc/smooth-signature

以上就是vue使用smooth-signature實(shí)現(xiàn)移動(dòng)端橫豎屏電子簽字的詳細(xì)內(nèi)容,更多關(guān)于vue smooth-signature電子簽字的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Vue3中使用ref與reactive創(chuàng)建響應(yīng)式數(shù)據(jù)的示例代碼

    Vue3中使用ref與reactive創(chuàng)建響應(yīng)式數(shù)據(jù)的示例代碼

    這篇文章主要介紹了Vue3中使用ref與reactive創(chuàng)建響應(yīng)式數(shù)據(jù)的方法,文中通過(guò)代碼示例講解的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下
    2024-08-08
  • vue之el-upload使用FormData多文件同時(shí)上傳問(wèn)題

    vue之el-upload使用FormData多文件同時(shí)上傳問(wèn)題

    這篇文章主要介紹了vue之el-upload使用FormData多文件同時(shí)上傳問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • nuxt 實(shí)現(xiàn)在其它js文件中使用store的方式

    nuxt 實(shí)現(xiàn)在其它js文件中使用store的方式

    這篇文章主要介紹了nuxt 實(shí)現(xiàn)在其它js文件中使用store的方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-11-11
  • Vue狀態(tài)管理工具Pinia的安裝與使用教程

    Vue狀態(tài)管理工具Pinia的安裝與使用教程

    這篇文章主要介紹了Vue狀態(tài)管理工具Pinia的安裝與使用,一步一步學(xué)習(xí)如何將pinia運(yùn)用到項(xiàng)目實(shí)戰(zhàn)中去,文中有詳細(xì)的安裝教程和使用方法,并通過(guò)代碼示例講解的非常詳細(xì),需要的朋友可以參考下
    2024-03-03
  • 搭建vue3項(xiàng)目以及按需引入element-ui框架組件全過(guò)程

    搭建vue3項(xiàng)目以及按需引入element-ui框架組件全過(guò)程

    element是基于vue.js框架開(kāi)發(fā)的快速搭建前端的UI框架,下面這篇文章主要給大家介紹了關(guān)于搭建vue3項(xiàng)目以及按需引入element-ui框架組件的相關(guān)資料,文中通過(guò)圖文以及代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-02-02
  • Vue中$attrs和$listeners詳解以及使用方法

    Vue中$attrs和$listeners詳解以及使用方法

    最近在研究Vue的組件庫(kù),之前也用過(guò)$attrs和$listeners,官方文檔描述的不太詳細(xì),也沒(méi)有太好的例子,下面這篇文章主要給大家介紹了關(guān)于Vue中$attrs和$listeners詳解以及使用的相關(guān)資料,需要的朋友可以參考下
    2022-11-11
  • vue實(shí)現(xiàn)整屏滾動(dòng)切換

    vue實(shí)現(xiàn)整屏滾動(dòng)切換

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)整屏滾動(dòng)切換,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-06-06
  • 基于Vue實(shí)現(xiàn)支持按周切換的日歷

    基于Vue實(shí)現(xiàn)支持按周切換的日歷

    這篇文章主要為大家詳細(xì)介紹了基于Vue實(shí)現(xiàn)支持按周切換的日歷,根據(jù)實(shí)際開(kāi)發(fā)情況按每年、每月、每周進(jìn)行切換,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • Vue3中簡(jiǎn)單實(shí)現(xiàn)動(dòng)態(tài)添加路由

    Vue3中簡(jiǎn)單實(shí)現(xiàn)動(dòng)態(tài)添加路由

    本文主要介紹了Vue3中簡(jiǎn)單實(shí)現(xiàn)動(dòng)態(tài)添加路由,,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-05-05
  • vue使用Split封裝通用拖拽滑動(dòng)分隔面板組件

    vue使用Split封裝通用拖拽滑動(dòng)分隔面板組件

    這篇文章主要介紹了vue使用Split封裝通用拖拽滑動(dòng)分隔面板組件,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-03-03

最新評(píng)論