t-watermark
Watermark 水印
组件介绍
t-watermark 是水印组件,用于在页面上添加水印效果,支持文字水印和图片水印。基于 Canvas 绘制,性能高。
平台兼容
| Harmony | H5 | Android | iOS | 小程序 | UTS |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
基础用法
基础用法参考 demo/watermark/watermark.uvue,通过 content 属性设置水印文本。
vue
<template>
<t-watermark content="欢迎使用Tui" class="h-500 bg-#fff">
<view class="content">
<text>页面内容</text>
</view>
</t-watermark>
</template>文字水印
vue
<template>
<t-watermark
content="欢迎使用Tui"
type="primary"
size="large"
:xSpace="150"
:ySpace="120">
<view class="content">
<text>大号-间距设置</text>
</view>
</t-watermark>
</template>图片水印
当 content 为图片路径时,显示图片水印。
vue
<template>
<t-watermark
content="/static/image/wark.png"
:xSpace="150"
:ySpace="120">
<view class="content">
<text>图片水印</text>
</view>
</t-watermark>
</template>Props
| 属性名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
content | 水印内容,文本或图片路径 | string | '' |
imageWidth | 图片水印宽度 | string | '' |
imageHidth | 图片水印高度 | string | '' |
angle | 水印角度 | number | -45 |
xSpace | 水平间距 | number | 100 |
ySpace | 垂直间距 | number | 80 |
size | 组件尺寸 | string | 'medium' |
type | 组件类型 | string | '' |
effect | 组件显示主题 | string | 'normal' |
Events
| 事件名 | 说明 | 回调参数 |
|---|---|---|
initFinished | 组件初始化完成触发 | (rect: NodeInfo) => void |
touchstart | 触摸开始 | (e: UniTouchEvent) => void |
touchmove | 触摸移动 | (e: UniTouchEvent) => void |
touchend | 触摸结束 | (e: UniTouchEvent) => void |
Slots
| 插槽名 | 说明 |
|---|---|
default | 水印覆盖的内容区域 |