mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-10 03:16:45 +08:00
2022年5月29日 从svn移到git
This commit is contained in:
80
components/watermark/watermark.vue
Normal file
80
components/watermark/watermark.vue
Normal file
@@ -0,0 +1,80 @@
|
||||
<template>
|
||||
<!-- 水印 -->
|
||||
<view class="watermark">
|
||||
<block v-for="(item,index) in num" :key="index">
|
||||
<view class="watermark-text" v-if="words != ''" :style="{opacity:opacity}">{{words}}</view>
|
||||
<image class="watermark-img" :src="imgUrl" mode="aspectFill" v-if="imgUrl !='' && words ==''" :style="{opacity:opacity}"></image>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
export default {
|
||||
name:'wm-watermark',
|
||||
props:{
|
||||
text:{ //设置水印文字
|
||||
type:String,
|
||||
default:''
|
||||
},
|
||||
imgUrl:{ //设置水印图片
|
||||
type:String,
|
||||
default:''
|
||||
},
|
||||
opacity:{ //设置透明度
|
||||
type:[Number,String],
|
||||
default:0.3
|
||||
},
|
||||
num:{ //设置水印数量
|
||||
type:Number,
|
||||
default:6
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
words:''
|
||||
};
|
||||
},
|
||||
computed:{
|
||||
...mapGetters(['userInfo'])
|
||||
},
|
||||
mounted() {
|
||||
if(this.text==''){
|
||||
this.words=this.userInfo.name+this.userInfo.loginName;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.watermark{
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top:0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
pointer-events: none;
|
||||
z-index: 9999999;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
overflow: hidden;
|
||||
.watermark-text{
|
||||
width: 375upx;
|
||||
height: 375upx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
transform: rotate(-36deg);
|
||||
color: #d4d4d4;
|
||||
font-size: 32upx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.watermark-img{
|
||||
width: 375upx;
|
||||
height: 375upx;
|
||||
z-index: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user