组件库文档 tmui.design
页面水印 Watermark
给页面加个水印,或给组件加个水印。[此组件,作者还未审核修改,目前权支持h5和web端,其它端待我有时间来适配下。]
🌶️ 页面水印 Watermark 示例
查看模拟效果+
示例模板
vue
<template>
<tm-app>
<tm-sheet :followDark="false">
<tm-text _class="text-weight-b" label="页面水印"></tm-text>
<tm-text :font-size="24" label="简单点,满足就好"></tm-text>
</tm-sheet>
<tm-watermark
selectable
:font-size="opts.fontSize"
:line-height="opts.lineHeight"
:fullscreen="opts.fullscreen"
:width="opts.width"
:height="opts.height"
:x-offset="opts.xOffset"
:y-offset="opts.yOffset"
:x-gap="opts.xGap"
:y-gap="opts.yGap"
:rotate="opts.rotate"
:content="opts.content"
:image="opts.image"
:image-width="opts.imageWidth"
:image-height="opts.imageHeight"
:image-opacity="opts.imageOpacity"
>
<tm-sheet>
<view class="flex flex-row flex-row-bottom-start">
<tm-text label="属性设置"></tm-text>
<tm-text :font-size="22" _class="ml-10" label="(实时生效)"></tm-text>
</view>
<tm-divider></tm-divider>
<tm-radio-group v-model="opts.fullscreen" :defaultValue="false">
<tm-radio :value="true" label="全屏幕"></tm-radio>
<tm-radio :value="false" label="包围内"></tm-radio>
</tm-radio-group>
<tm-divider></tm-divider>
<tm-input prefixLabel="文本内容" align="right" placeholder="请输入文本" v-model="opts.content"></tm-input>
<tm-input
:margin="[0, 24]"
prefixLabel="字体大小"
align="right"
placeholder="请输入字号"
v-model.number="opts.fontSize"
type="number"
></tm-input>
<tm-input prefixLabel="字体行高" align="right" placeholder="请输入行高" v-model.number="opts.lineHeight" type="number"></tm-input>
<tm-input
:margin="[0, 24]"
prefixLabel="旋转角度"
align="right"
placeholder="请输入旋转角度"
v-model.number="opts.rotate"
type="number"
></tm-input>
<tm-input prefixLabel="宽度" align="right" placeholder="请输入宽度" v-model.number="opts.width" type="number"></tm-input>
<tm-input
:margin="[0, 24]"
prefixLabel="高度"
align="right"
placeholder="请输入高度"
v-model.number="opts.height"
type="number"
></tm-input>
<tm-input prefixLabel="x 轴间隔" align="right" placeholder="请输入x 轴间隔" v-model.number="opts.xGap" type="number"></tm-input>
<tm-input
:margin="[0, 24]"
prefixLabel="y 轴间隔"
align="right"
placeholder="请输入y 轴间隔"
v-model.number="opts.yGap"
type="number"
></tm-input>
<tm-input prefixLabel="x 轴偏移" align="right" placeholder="请输入x 轴偏移" v-model.number="opts.xOffset" type="number"></tm-input>
<tm-input
:margin="[0, 24]"
prefixLabel="y 轴偏移"
align="right"
placeholder="请输入y 轴偏移"
v-model.number="opts.yOffset"
type="number"
></tm-input>
<tm-upload
:width="636"
@change="handleUpload"
:rows="1"
:maxFile="1"
url="https://mockapi.eolink.com/tNYKNA7ac71aa90bcbe83c5815871a5b419601e96a5524d/upload"
></tm-upload>
<tm-input
:margin="[0, 24]"
prefixLabel="图片宽度"
align="right"
placeholder="请输入图片宽度"
v-model.number="opts.imageWidth"
type="number"
></tm-input>
<tm-input
prefixLabel="图片高度"
align="right"
placeholder="请输入图片高度"
v-model.number="opts.imageHeight"
type="number"
></tm-input>
<tm-input
:margin="[0, 24]"
prefixLabel="图片透明度"
align="right"
placeholder="请输入图片透明度"
v-model.number="opts.imageOpacity"
type="number"
></tm-input>
</tm-sheet>
</tm-watermark>
</tm-app>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import TmWatermark from '../../tmui/components/tm-watermark/tm-watermark.vue'
import TmSheet from '../../tmui/components/tm-sheet/tm-sheet.vue'
import TmText from '../../tmui/components/tm-text/tm-text.vue'
import TmDivider from '../../tmui/components/tm-divider/tm-divider.vue'
import TmRadio from '../../tmui/components/tm-radio/tm-radio.vue'
import TmRadioGroup from '../../tmui/components/tm-radio-group/tm-radio-group.vue'
import TmInput from '../../tmui/components/tm-input/tm-input.vue'
import TmApp from '../../tmui/components/tm-app/tm-app.vue'
import TmUpload from '../../tmui/components/tm-upload/tm-upload.vue'
const opts = ref({
content: 'TMUI',
fontSize: 12,
lineHeight: 12,
fullscreen: false,
width: 60,
height: 60,
xGap: 0,
yGap: 0,
xOffset: 14,
yOffset: 30,
rotate: -20,
image: '',
imageOpacity: 0.24,
imageWidth: 60,
imageHeight: 60
})
function handleUpload(res) {
opts.value.image = res[0].url
}
</script>
🌶️ 兼容性
APP-VUE | APP-NVUE | 小程序 | WEB/H5 | VUE3/TS |
---|---|---|---|---|
❌ | ❌ | ❌ | ✔️ | ✔️ |
🌱 参数
参数名 | 类型 | 默认值 | 描述 |
---|---|---|---|
content | string | undefined | 水印文本 |
cross | boolean | false | 是否跨越边界显示 |
debug | boolean | false | 是否显示调试信息 |
font-size | number | 14 | 字体大小 |
font-family | string | undefined | 字体族 |
font-style | 'normal' | 'italic' / 'oblique ${number}deg' | normal |
font-variant | string | '' | 字型 |
font-weight | number | 400 | 字重 |
font-color | string | rgba(128, 128, 128, .3) | 字体颜色 |
fullscreen | boolean | false | 是否展示全屏 |
line-height | number | 14 | 行高 |
height | number | 32 | 高度 |
image | string | undefined | 图片路径 |
image-height | number | undefined | 图片高度 |
image-opacity | number | 1 | 图片不透明度 |
image-width | number | undefined | 图片宽度 |
rotate | number | 0 | 旋转角度 |
selectable | boolean | true | 被水印覆盖的内容是否可选中 |
width | number | 32 | 宽度 |
x-gap | number | 0 | x 轴间隔 |
x-offset | number | 0 | x 轴偏移 |
y-gap | number | 0 | y 轴间隔 |
y-offset | number | 0 | y 轴偏移 |
z-index | number | 10 | z 轴高度 |
🌽 slot插槽
默认default
🥗 ref方法
无
方法名 | 参数 | 返回值 | 描述 |
---|