编程语言
首页 > 编程语言> > 微信小程序加水印(含代码)

微信小程序加水印(含代码)

作者:互联网

watermark.wxml组件

<view class="water_top" style="pointer-events: none;">
    <view class="water-text" wx:for="{{50}}">{{watermarkText}}</view>
</view>

watermark.wxss

  .water_top{
    position: fixed;
    top:0;
    bottom: 0;
    left: 0;
    right: 0;
    /* background: #999; */
    transform:rotate(-10deg);
    /* opacity: 0.9; */
    z-index: 9999999999;
  }
  .water-text{
    float: left;
    width:375rpx;
    color: rgba(169,169,169,.2);
    text-align: center;
    font-size: 40rpx;
    margin: 100rpx 0;
  }
  .watermark {
    position: fixed;
    top: 0;
    width: 100%;
    height: 100%;
    background: #eeeeee11;
    pointer-events: none;
    background-repeat: repeat;
    background-size: 50% auto;
}
.canvas {
    width: 200px;
    height: 200px;
    position: fixed;
    left: -200%;
}

watermark.js

// watermark.js
Component({
  data: {
    // 这里是一些组件内部数据
    watermarkText: '测试的水印代码'
  },
  attached() {
    // 在组件实例进入页面节点树时执行
    // this.drowsyUserinfo()
    this.setData({
      watermarkText: '橋本 環奈'
    })
  },
  methods: {

}
})

page wxml

<canvas-watermark id="watermark"></canvas-watermark>

效果图

 

标签:加水,watermark,watermarkText,微信,代码,width,169,background,top
来源: https://blog.csdn.net/sinat_28384025/article/details/120845506