watermark-unique
v1.0.3
Published
前端水印
Downloads
8
Readme
Watermark
前端添加水印
使用(Usage)
方式:安装npm包导入到需要使用的项目中去:
npm install watermark-unique
// import
import Watermark from 'watermark-unique'
导入后就可以调用下面的方法
Watermark.setWaterMark
使用时该方法时传入一个 options 配置对象, 配置对象主要有两个属性:wTexts
、wOptions
。
wTexts
:水印文案的数组集合可设置多行文案。
wOptions
:水印参数配置项,如字体大小、颜色、透明度,不传会有默认设置等
import Watermark from 'watermark-unique'
Watermark.setWaterMark(
{
wTexts: ['水印', 'watermark']
}
)
options 配置对象还有另一个属性 wOptions
水印参数配置: 用于设置水印的具体参数如宽度,大小等,各参数说明见下表
import Watermark from 'watermark-unique'
Watermark.setWaterMark(
{
wTexts: ['水印', 'watermark'],
wOptions: {
wWidth: 200,
wHeight: 140,
wTop: '0px',
wLeft: '0px',
wRotateDeg: 25,
wFontSize: '1.2rem',
wFont: '1.2rem Vedana',
wColor: '#666',
wOpacity: '0.2',
wZIndex: '100000',
}
}
)
| key | value | default value |
|:--|:--|:--|
| wWidth
| A number
that the width of the watermark block.(水印块宽度) | 240 |
| wHeight | A number
that the height of the watermark block.(水印块高度) | 140 |
| wTop | A string
that the distance between the watermark mask layer and the top of the page.(水印遮罩层距离页面顶部的距离) | '0px' |
| wLeft | A string
that the distance between the watermark mask layer and the left of the page.(水印遮罩层距离页面左边的距离) | '0px' |
| wRotateDeg | A string
that specifies SameSite attribute that restricts cookie access based on the site context.(水印角度) | 25 |
| wFontSize | A string
that the watermark font size(水印的字体大小,与下面的wFont任选一个设置) | '1.2rem' |
| wFont | A string
that the watermark font size, font style(水印的字体大小、字体风格) | '1.2rem Vedana' |
| wColor | A string
that the watermark font color(水印字体颜色) | '#666' |
| wOpacity | A string
that the watermark mask layer transparency(水印遮罩层透明度) | '0.2' |
| wZIndex | A string
that the zIndex of watermark mask(水印遮罩层层级) | 10000 |
Watermark.removeWatermark
清除水印
Watermark.removeWatermark()