wm-watermark.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <!-- 水印 -->
  3. <view class="watermark_big" :style='{height:height?height+"px":"100%"}'>
  4. <view v-for="(item,index) in num" :key="index">
  5. <view class="watermark-text" v-if="text != ''" :style="{opacity:opacity}"><text style='color: #efefef;font-size: 26rpx;'>{{text}}</text></view>
  6. <image class="watermark-img" :src="imgUrl" mode="aspectFill" v-if="imgUrl !='' && text ==''" :style="{opacity:opacity}"></image>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. name:'wm-watermark',
  13. props:{
  14. height:{
  15. type:Number,//动态设置屏幕高度
  16. default:0
  17. },
  18. text:{ //设置水印文字
  19. type:String,
  20. default:''
  21. },
  22. imgUrl:{ //设置水印图片
  23. type:String,
  24. default:''
  25. },
  26. opacity:{ //设置透明度
  27. type:[Number,String],
  28. default:0.8
  29. },
  30. num:{ //设置水印数量
  31. type:Number,
  32. default:6
  33. }
  34. },
  35. data() {
  36. return {
  37. };
  38. },
  39. }
  40. </script>
  41. <style scoped>
  42. .watermark_big{
  43. position: fixed;
  44. width: 750rpx;
  45. top:0;
  46. left: 0;
  47. bottom: 0;
  48. right: 0;
  49. /* pointer-events: none; */
  50. z-index: 9999;
  51. /* display: flex; */
  52. flex-wrap: wrap;
  53. overflow: hidden;
  54. flex-direction: column;
  55. }
  56. .watermark-text{
  57. width: 250rpx;
  58. height: 250rpx;
  59. flex-direction: column;
  60. justify-content: center;
  61. align-items: center;
  62. transform: rotate(-36deg);
  63. z-index: 9999;
  64. /* white-space: nowrap; */
  65. }
  66. .watermark-img{
  67. width: 375rpx;
  68. height: 375rpx;
  69. z-index: 1;
  70. }
  71. </style>