2.6.0 • Published 11 months ago

vue-signature v2.6.0

Weekly downloads
1,400
License
MIT
Repository
github
Last release
11 months ago

vue-signature

A electronic signature component by Vue.js

Reference and Thanks

signature_pad

API


Props

w,h need units,like 100px or 100%

nametypedefaultdescription
sigOptionObject{penColor:"rgb(0, 0, 0)", backgroundColor:"rgb(255,255,255)"}penColor, backgroundColor
wString"100%"parent container width
hString"100%"parent container height
clearOnResizeBooleanfalseCanvas is cleared on window resize
waterMarkObject{}check Usage addWaterMark
disabledBooleanfalsedisabled
defaultUrlString""you want show image by default

Methods

nameparamsdescription
save()/("image/jpeg")/("image/svg+xml")save image as PNG/JPEG/SVG
clearclear canvas
isEmptyReturns true if canvas is empty, otherwise returns false
undoremove the last dot or line
addWaterMark{} // check Usage addWaterMarkaddWaterMark
fromDataURL(url)Draws signature image from data URL.

Usage


npm install vue-signature 

main.js

import vueSignature from "vue-signature"
Vue.use(vueSignature)

A.vue

<template>
	<div id="app">
		<vueSignature ref="signature" :sigOption="option" :w="'800px'" :h="'400px'" :disabled="disabled" :defaultUrl="dataUrl"></vueSignature> 
		<vueSignature ref="signature1" :sigOption="option"></vueSignature> 
		<button @click="save">Save</button>
		<button @click="clear">Clear</button>
		<button @click="undo">Undo</button>
		<button @click="addWaterMark">addWaterMark</button>
		<button @click="handleDisabled">disabled</button>
	</div>
</template>

<script>
export default {
	name: "app",
	data() {
		return {
			option:{
				penColor:"rgb(0, 0, 0)",
				backgroundColor:"rgb(255,255,255)"
			},
			disabled:false,
			dataUrl:"https://avatars2.githubusercontent.com/u/17644818?s=460&v=4"
		};
	},
	methods:{
		save(){
			var _this = this;
			var png = _this.$refs.signature.save()
			var jpeg = _this.$refs.signature.save('image/jpeg')
			var svg = _this.$refs.signature.save('image/svg+xml');
			console.log(png);
			console.log(jpeg)
			console.log(svg)
		},
		clear(){
			var _this = this;
			_this.$refs.signature.clear();
		},
		undo(){
			var _this = this;
			_this.$refs.signature.undo();
		},
		addWaterMark(){
			var _this = this;
			_this.$refs.signature.addWaterMark({
				text:"mark text",          // watermark text, > default ''
				font:"20px Arial",         // mark font, > default '20px sans-serif'
				style:'all',               // fillText and strokeText,  'all'/'stroke'/'fill', > default 'fill		
				fillStyle:"red",           // fillcolor, > default '#333' 
				strokeStyle:"blue",	   // strokecolor, > default '#333'	
				x:100,                     // fill positionX, > default 20
				y:200,                     // fill positionY, > default 20				
				sx:100,                    // stroke positionX, > default 40
				sy:200                     // stroke positionY, > default 40
			});
		},
		fromDataURL(url){
			var _this = this;
			_this.$refs.signature.fromDataURL("data:image/png;base64,iVBORw0K...");
		},
		handleDisabled(){
			var _this = this;
			_this.disabled  = !_this.disabled
		}
	}
};
</script>

License


Released under the MIT License.

2.6.0

11 months ago

2.5.6

2 years ago

2.5.5

2 years ago

2.5.4

3 years ago

2.5.3

3 years ago

2.5.2

3 years ago

2.5.1

3 years ago

2.4.7

4 years ago

2.4.6

4 years ago

2.4.5-alpha.12

4 years ago

2.4.5-alpha.11

4 years ago

2.4.5-alpha.10

4 years ago

2.4.5-alpha.9

4 years ago

2.4.5-alpha.8

4 years ago

2.4.5-alpha.7

4 years ago

2.4.5-alpha.6

4 years ago

2.4.5-alpha.5

4 years ago

2.4.5-alpha.4

4 years ago

2.4.5-alpha.3

4 years ago

2.4.5-alpha.2

4 years ago

2.4.5-alpha.1

4 years ago

2.4.5-alpha.0

4 years ago

2.4.5

4 years ago

2.4.4

4 years ago

2.4.3

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.3

6 years ago

2.3.2

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.9.1

6 years ago

1.9.0

6 years ago

1.8.0

6 years ago

1.7.0

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.0

7 years ago