Skip to content
本页导读

Watermark

组件类型:UxWatermarkComponentPublicInstance

支持局部水印,支持全屏水印

平台兼容性

UniApp X

AndroidiOSweb鸿蒙 Next小程序
x

UniApp Vue Nvue

AndroidiOSweb鸿蒙 Next小程序
xxxx

Props

属性名类型默认值说明
modeStringtext模式
contentString水印文字
colorStringrgba(0,0,0,0.2)水印颜色
darkColorStringrrgba(255,255,255,0.8)深色
sizeAny16文字大小
imgWidthAny60图片宽
imgHeightAny30图片高
gutterAny25间隙
fullscreenBoolean全屏

mode

说明
text文本
img图片暂不支持

示例代码

html
<template>
	<ux-page :stack="showDoc">
		<ux-navbar :title="title" :bold="true">
			<template v-slot:right>
				<!-- #ifndef MP -->
				<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
				<!-- #endif -->
			</template>
		</ux-navbar>
		
		<ux-scroll>
			<ux-card direction="column" icon="flag-filled" title="水印" :bold="true">
				<ux-text text="支持局部水印,支持全屏水印"></ux-text>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="文字水印" :bold="true">
				<ux-text text="支持局部水印,适配暗黑模式" :mb="15"></ux-text>
				<view style="width: 100%; height: 150px;">
					<ux-watermark content="UxFrame"></ux-watermark>
				</view>
			</ux-card>
			
			<!-- <ux-card direction="column" icon="arrowright" title="图片水印" :bold="true">
				<view style="flex: 1; height: 150px;">
					<ux-watermark mode="img" content="/static/logo.png"></ux-watermark>
				</view>
			</ux-card> -->
			
			<ux-placeholder :height="200">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
		</ux-scroll>
		
		<ux-watermark content="铺满屏幕" :fullscreen="true" :gutter="40" color="rgba(0,0,0,0.05)" dark-color="rgba(255,255,255,0.05)"></ux-watermark>
	</ux-page>
</template>
<template>
	<ux-page :stack="showDoc">
		<ux-navbar :title="title" :bold="true">
			<template v-slot:right>
				<!-- #ifndef MP -->
				<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
				<!-- #endif -->
			</template>
		</ux-navbar>
		
		<ux-scroll>
			<ux-card direction="column" icon="flag-filled" title="水印" :bold="true">
				<ux-text text="支持局部水印,支持全屏水印"></ux-text>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="文字水印" :bold="true">
				<ux-text text="支持局部水印,适配暗黑模式" :mb="15"></ux-text>
				<view style="width: 100%; height: 150px;">
					<ux-watermark content="UxFrame"></ux-watermark>
				</view>
			</ux-card>
			
			<!-- <ux-card direction="column" icon="arrowright" title="图片水印" :bold="true">
				<view style="flex: 1; height: 150px;">
					<ux-watermark mode="img" content="/static/logo.png"></ux-watermark>
				</view>
			</ux-card> -->
			
			<ux-placeholder :height="200">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
		</ux-scroll>
		
		<ux-watermark content="铺满屏幕" :fullscreen="true" :gutter="40" color="rgba(0,0,0,0.05)" dark-color="rgba(255,255,255,0.05)"></ux-watermark>
	</ux-page>
</template>
ts
<script setup>
	
	import * as plus from '@/uni_modules/ux-plus'
	
	const title = ref('')
	const showDoc = ref(false)
	
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/watermark.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	onLoad((e: OnLoadOptions) => {
		title.value = e['title'] ?? ''
	})
</script>
<script setup>
	
	import * as plus from '@/uni_modules/ux-plus'
	
	const title = ref('')
	const showDoc = ref(false)
	
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/watermark.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	onLoad((e: OnLoadOptions) => {
		title.value = e['title'] ?? ''
	})
</script>
css
<style lang="scss">
	
</style>
<style lang="scss">
	
</style>