酷炫直播运营系统小程序版本

wm-watermark.vue 1.4KB

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