Personal implementation screenshots: Install:
use: 1. Import in main.js import vueEsign from 'vue-esign' Vue.use(vueEsign) 2. Quote in the page <vue-esign ref="esign" :width="800" :height="300" :isCrop="isCrop" :lineWidth="lineWidth" :lineColor="lineColor" :bgColor.sync="bgColor" /> <button @click="handleReset">Clear the drawing board</button> <button @click="handleGenerate">Generate image</button> 3. Description
Long awaited, here is the original code: data () { return { lineWidth: 6, lineColor: '#000000', bgColor: '', resultImg: '', isCrop: false } }, methods: { handleReset () { this.$refs['esign'].reset() //Clear the canvas}, handleGenerate() { this.$refs['esign'].generate().then(res => { this.resultImg = res // Get the base64 image generated by the signature}).catch(err => { // No signature, call this.$message({ message: err + ' Unsigned! ', type: 'warning' }) alert(err) // This will be executed when the canvas is not signed'Not Signned' }) } } Appendix : How to convert base64 into pictures: // Convert base64 to image base64ImgtoFile(dataurl, filename = 'file') { const arr = dataurl.split(',') const mime = arr[0].match(/:(.*?);/)[1] const suffix = mime.split('/')[1] const bstr = atob(arr[1]) let n = bstr.length const u8arr = new Uint8Array(n) while (n--) { u8arr[n] = bstr.charCodeAt(n) } return new File([u8arr], `${filename}.${suffix}`, { type: mime }) }, This is the end of this article about using vue to implement handwritten signature function. For more relevant vue implementation of handwritten signature content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Setting up VMware vSphere in VMware Workstation (Graphic Tutorial)
>>: VMware ESXi 6.0 and deployment of virtual machine installation tutorial (picture and text)
Download Download address: https://dev.mysql.com/...
Table of contents 1. What is redux? 2. The princi...
Let me look at the example code first: 1. Common ...
[Who is nslookup?] 】 The nslookup command is a ve...
<html> <head> <meta http-equiv=&quo...
1. Download address: http://dev.mysql.com/downloa...
Experimental environment A minimally installed Ce...
1.1. Download: Download the zip package from the ...
Table of contents 1. Quick understanding of conce...
Precondition: content="width=750" <m...
I think everyone often worries about finding pict...
Docker view process, memory, cup consumption Star...
Vuex is a state management pattern developed spec...
This article shares the specific code of the canv...
This article introduces the CSS scrollbar selecto...