Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

watermark-vue3

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

watermark-vue3

A lightweight Vue3 component for adding custom watermarks to web pages.

latest
Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
4
-55.56%
Maintainers
1
Weekly downloads
 
Created
Source

English Document

watermark-vue3

一个可以在网页中添加自定义水印的Vue3组件。

简介

watermark-vue3是一个基于Vue3编写的用于在网页中添加自定义水印的轻量级组件。使用该组件,您可以自由设置水印文字、字体大小、字体、颜色、旋转角度、透明度、宽度和高度等参数,轻松实现水印效果。

安装

通过npm安装:

npm install watermark-vue3

使用方法

  • 引入Watermark组件:
<template>
  <Watermark :options="options" :visible="true"/>
</template>

<script setup lang="ts">
import Watermark from 'watermark-vue3';

const options = {
  text: '我是水印',
  fontSize: 14,
  fontFamily: 'Microsoft YaHei',
  color: 'rgba(0, 0, 0, 0.3)',
  rotate: -30,
  opacity: 0.5,
  width: 200,
  height: 100,
};
</script>
  • 在要添加水印的元素上加上相对或固定定位:
.watermark-wrap {
  position: relative;
}

属性

属性名类型默认值说明
optionsObject见下方默认值水印设置,包括文字、字体大小、字体、颜色、旋转角度、透明度、宽度和高度等
visibleBooleantrue是否显示水印

options属性的默认值

属性名类型默认值说明
textString | Array'我是水印'水印文字,字符串或字符串数组
fontSizeNumber14字体大小
fontFamilyString'Microsoft YaHei'字体
colorString'rgba(0, 0, 0, 0.3)'颜色
rotateNumber-30旋转角度,单位为度数
opacityNumber0.5透明度
widthNumber200宽度
heightNumber100高度

示例

<template>
  <div class="watermark-wrap">
    <img src="image.jpg" alt="">
    <Watermark :options="options" :visible="true"/>
  </div>
</template>

<script setup lang="ts">
import Watermark from 'watermark-vue3';

const options = {
  text: ['仅供测试使用', '请勿商用'],
  fontSize: 18,
  fontFamily: 'Arial',
  color: 'rgba(255, 0, 0, 0.2)',
  rotate: -45,
  opacity: 0.6,
  width: 300,
  height: 150,
};
</script>

<style scoped>
.watermark-wrap {
  position: relative;
}
</style>

Keywords

watermark

FAQs

Package last updated on 16 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts