Number1 微信小程序增加水印
最近在整微信小程序,这里增加写自己最近用到的东西(仅为记录)
主要原则是增加一个水印的组件,新建components文件夹,在文件夹下面新建watermark组件
1、watermark.js源码
Component({
/**
* 组件的属性列表
*/
properties: {
myValue: String
},
data: {
text: '内容自定义',
// color: 'rgba(0,0,0,0.03)',
color: 'rgba(0,0,0,0.5)',
rows: [],
cols: []
},
// 组件在页面上挂载时触发,注意如果页面没卸载过,该事件就不会触发第二次
attached() {
const { windowWidth, windowHeight } = wx.getSystemInfoSync();
const rows = Math.ceil(windowWidth / (30 * this.data.text.length));
const cols = Math.ceil(windowHeight / 100);
this.setData({
rows: new Array(rows),
cols: new Array(cols)
});
},
})
2、watermark.json
{
"component": true,
"usingComponents": {}
}
3、wat