import{_ as s,o as a,c as n,V as l}from"./chunks/framework.b31a4d00.js";const d=JSON.parse('{"title":"@fesjs/plugin-watermark","description":"","frontmatter":{},"headers":[],"relativePath":"reference/plugin/plugins/watermark.md"}'),p={name:"reference/plugin/plugins/watermark.md"},o=l(`
给页面添加水印效果
在 package.json
中引入依赖:
{
"dependencies": {
"@fesjs/fes": "^3.0.0",
"@fesjs/plugin-watermark": "^3.0.0"
}
}
export default {
watermark: {
disabled: false,
},
};
是否禁用水印,默认是false
。
可以在开发环境关闭水印:
export default {
watermark: {
disabled: true,
},
};
创建水印功能,通过 @fesjs/fes
导入 API:
import { createWatermark, destroyWatermark } from '@fesjs/fes';
createWatermark({ content: '我是水印' }); // 生成水印
destroyWatermark(); // 销毁水印
默认参数是:
{
(content = '请勿外传'),
(container = document.body),
(width = 300),
(height = 300),
(textAlign = 'center'),
(textBaseline = 'middle'),
(fontSize = '14px'),
(fontFamily = 'Microsoft Yahei'),
(fillStyle = 'rgba(184, 184, 184, 0.3)'),
(rotate = 25),
(zIndex = 99999),
(timestamp = 'YYYY-MM-DD HH:mm');
}
如果不需要时间戳,则可以设置timestamp
为false
。