73 lines
1.3 KiB
Vue
73 lines
1.3 KiB
Vue
<template>
|
|
<!-- 水印 -->
|
|
<view class="watermark">
|
|
<block v-for="(item,index) in num" :key="index">
|
|
<view class="watermark-text" v-if="text != ''" :style="{opacity:opacity}">{{text}}</view>
|
|
<image class="watermark-img" :src="imgUrl" mode="aspectFill" v-if="imgUrl !='' && text ==''" :style="{opacity:opacity}"></image>
|
|
</block>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name:'wm-watermark',
|
|
props:{
|
|
text:{ //设置水印文字
|
|
type:String,
|
|
default:''
|
|
},
|
|
imgUrl:{ //设置水印图片
|
|
type:String,
|
|
default:''
|
|
},
|
|
opacity:{ //设置透明度
|
|
type:[Number,String],
|
|
default:0.6
|
|
},
|
|
num:{ //设置水印数量
|
|
type:Number,
|
|
default:30
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
|
|
};
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.watermark{
|
|
position: fixed;
|
|
width: 1200upx;
|
|
height: 100%;
|
|
top:0;
|
|
left: 0;
|
|
bottom: 0;
|
|
right: 0;
|
|
pointer-events: none;
|
|
z-index: 9999999;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
overflow: hidden;
|
|
transform: rotate(-33deg) translateX(-20px);
|
|
.watermark-text{
|
|
width: 350upx;
|
|
height: 80upx;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
// color: red;
|
|
color: rgba(0,0,0,0.1);
|
|
font-size: 18upx;
|
|
white-space: nowrap;
|
|
}
|
|
.watermark-img{
|
|
width: 375upx;
|
|
height: 375upx;
|
|
z-index: 1;
|
|
}
|
|
}
|
|
</style>
|