Skip to content

Watermark 水印

给页面的某个区域加上水印。

代码演示

基础用法

vue
<template>
  <a-watermark content="Ant Design Vue">
    <div style="height: 500px" />
  </a-watermark>
</template>

多行水印

通过 content 设置 字符串数组 指定多行文字水印内容。

vue
<template>
  <a-watermark :content="['Ant Design Vue', 'Happy Working']">
    <div style="height: 500px" />
  </a-watermark>
</template>

图片水印

通过 image 指定图片地址。为保证图片高清且不被拉伸,请设置 width 和 height, 并上传至少两倍的宽高的 logo 图片地址。

vue
<template>
  <a-watermark
    :height="30"
    :width="130"
    image="https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*lkAoRbywo0oAAAAAAAAAAAAADrJ8AQ/original"
  >
    <div style="height: 500px" />
  </a-watermark>
</template>

API

Watermark

参数说明类型默认值
width水印的宽度,content 的默认值为自身的宽度number120
height水印的高度,content 的默认值为自身的高度number64
rotate水印绘制时,旋转的角度,单位 °number-22
zIndex追加的水印元素的 z-indexnumber9
image图片源,建议导出 2 倍或 3 倍图,优先级高string-
content水印文字内容string | string[]-
font文字样式FontFont
gap水印之间的间距[number, number][100, 100]
offset水印距离容器左上角的偏移量,默认为 gap/2[number, number][gap[0]/2, gap[1]/2]

Font

参数说明类型默认值
color字体颜色stringrgba(0,0,0,.15)
fontSize字体大小number16
fontWeight字体粗细normal | light | weight | numbernormal
fontFamily字体类型stringsans-serif
fontStyle字体样式none | normal | italic | obliquenormal