Skip to content

Watermark Component

Add a specified image or text to a page or component, which can be used for scenarios such as copyright protection and brand promotion.

📌 Platform Difference Notes

APP(vue)H5WeChat Mini ProgramAlipay Mini Program

🏯 Basic Usage Example

html
<!-- Global usage -->
<hy-watermark content="Huayue Component Library"></hy-watermark>

Image Watermark

  • By setting image, set a network image URL or Base64 image
  • image-width: watermark image width
  • image-height: watermark image height

Note

The DingTalk Mini Program platform only supports network images

html
<template>
    <hy-watermark
        image="https://pic1.imgdb.cn/item/67f8dfea88c538a9b5caea38.png"
        :image-width="38"
        :image-height="38"
    ></hy-watermark>
</template>

Partial Watermark

  • By setting full-screen, set whether it is a full-screen watermark (if full-screen is false, it is a partial watermark).
html
<template>
    <hy-watermark
        image="https://pic1.imgdb.cn/item/67f8dfea88c538a9b5caea38.png"
        :full-screen="false"
    ></hy-watermark>
</template>

Custom Z-Index and Opacity

  • By setting image, set a network image URL or Base64 image; set the watermark image width and height via the image-width and image-height fields.
html
<template>
    <hy-watermark image="https://pic1.imgdb.cn/item/67f8dfea88c538a9b5caea38.png"></hy-watermark>
</template>

Watermark Spacing

  • By setting gutterX, set the spacing distance along the x-axis.
  • By setting gutterY, set the spacing distance along the y-axis.
html
<template>
    <hy-watermark
        image="https://pic1.imgdb.cn/item/67f8dfea88c538a9b5caea38.png"
        :gutterX="40"
        :gutterY="40"
    ></hy-watermark>
</template>

Canvas Width

  • By setting width, set the width of a single watermark canvas.
  • By setting height, set the height of a single watermark canvas.
html
<template>
    <hy-watermark
        image="https://pic1.imgdb.cn/item/67f8dfea88c538a9b5caea38.png"
        :width="200"
        :height="200"
    ></hy-watermark>
</template>

Watermark Font Settings

  • By setting color, set the watermark font color.
  • By setting size, set the watermark font size.
  • By setting fontStyle, set the watermark font style.
  • By setting fontWeight, set the watermark font weight.
  • By setting fontFamily, set the watermark font family.
html
<template>
    <hy-watermark
        image="https://pic1.imgdb.cn/item/67f8dfea88c538a9b5caea38.png"
        color="red"
        :size="23"
    ></hy-watermark>
</template>

Watermark Rotation Angle

  • By setting rotate, set the watermark rotation angle.
html
<template>
    <hy-watermark
        image="https://pic1.imgdb.cn/item/67f8dfea88c538a9b5caea38.png"
        :rotate="25"
    ></hy-watermark>
</template>

Watermark Opacity

  • By setting opacity, set the watermark opacity.
html
<template>
    <hy-watermark
        image="https://pic1.imgdb.cn/item/67f8dfea88c538a9b5caea38.png"
        :opacity="1"
    ></hy-watermark>
</template>

Anti-Deletion ^0.6.4

  • By setting isAntiTheft, prevent the watermark image from being deleted or tampered with.
html
<template>
    <hy-watermark text="Huayue Component Library" :isAntiTheft="true"></hy-watermark>
</template>

API

Watermark Props

ParameterDescriptionTypeDefault
titleTitlestring-
contentContent to displaystring-
imageImage URL to display, supports network images and base64string-
imageHeightImage height, default unit pxnumber50
imageWidthImage width, default unit pxnumber70
gutterXX-axis spacing, default unit pxnumber0
gutterYY-axis spacing, default unit pxnumber0
widthCanvas width, default unit pxnumber100
heightCanvas height, default unit pxnumber100
fullScreenWhether it is a full-screen watermarkbooleantrue
titleSizeWhether it is a full-screen watermarkbooleantrue
titleColorWhether it is a full-screen watermarkbooleantrue
colorWatermark font colorstring#8c8c8c
sizeWatermark font size, default unit pxnumber14
fontStyleWatermark font style (only supported on WeChat, Alipay, and h5)normal|italic|obliquenormal
fontWeightWatermark font weight (only supported on WeChat, Alipay, and h5)normal|bold|boldernormal
fontFamilyWatermark font family (only supported on WeChat, Alipay, and h5)stringPingFang SC
rotateWatermark rotation anglenumber-25
zIndexCustom z-indexnumber10086
opacityCustom opacity, value range 0~1number0.5
isAntiTheftv0.6.4Anti-deletion and anti-style-tampering feature (effective on h5)booleanfalse
03:29