1.0.7 • Published 2 years ago

zxwatermark v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

zxwatermark

前端添加水印


更新日志

v1.0.0 初始版本 最好用 1.0.4 以后的 v1.0.4 修改版本导入需要.default 问题 v1.0.5 添加关键字


使用(Usage)

**方式:安装 npm 包导入到需要使用的项目中去:

npm i zxwatermark--save

// import
import watermark from 'zxwatermark'

导入后就可以调用下面的方法

(After that you can call any of methods that are explained in the following)


watermark.setWaterMark

使用时该方法时传入一个 options 配置对象, 配置对象主要有两个属性:w_textsw_optionsw_texts:水印文案的数组集合可设置多行文案。 w_options:水印参数配置项,如字体大小、颜色等

You can use the watermark.setWaterMark method to set watermark. The value will automatically be escaped for you.

import watermark from "zxwatermark";
// w_texts:水印文案数组集合
watermark.setWaterMark({
  w_texts: ["zzz", "xxxx"],
});

options 配置对象还有另一个属性 w_options水印参数配置: 用于设置水印的具体参数如宽度,大小等,各参数说明见下表

If you need more options, like setting the width, you can add an object with options as the last parameter:

import watermark from "watermark-package";
watermark.setWaterMark({
  w_texts: ["zzz", "xxx"],
  w_options: {
    w_width: 240,
    w_height: 140,
    w_top: "0px",
    w_left: "0px",
    w_rotateDeg: 25,
    w_font: "1.2rem Vedana",
    w_color: "#666",
    w_opacity: "0.2",
    w_zIndex: "100000",
  },
});
keyvaluedefault value
w_widthA number that the width of the watermark block.(水印块宽度)240
w_heightA number that the height of the watermark block.(水印块高度)140
w_topA string that the distance between the watermark mask layer and the top of the page.(水印遮罩层距离页面顶部的距离)'0px'
w_leftA string that the distance between the watermark mask layer and the left of the page.(水印遮罩层距离页面左边的距离)'0px'
w_rotateDegA string that specifies SameSite attribute that restricts cookie access based on the site context.(水印角度)25
w_fontA string that the watermark font size, font style(水印的字体大小、字体风格)'1.2rem Vedana'
w_colorA string that the watermark font color(水印字体颜色)'#666'
w_opacityA string that the watermark mask layer transparency(水印遮罩层透明度)'0.2'
w_zIndexA string that the zIndex of watermark mask(水印遮罩层层级)10000

watermark.removeWatermark

清除水印

clear watermark