原理:通過動態生成canvas然後轉為base64格式 代碼Demo export const waterMark = (text) = { let _wm = document.createElement('canvas') _wm.setAttribute('width',150) _wm.se ...
原理:通過動態生成canvas然後轉為base64格式
代碼Demo
export const waterMark = (text) =>{
let _wm = document.createElement('canvas')
_wm.setAttribute('width',150)
_wm.setAttribute('height',100)
let ctx = _wm.getContext('2d')
ctx.fillStyle = '#d2d2d2'
ctx.font= "13px 宋體"
ctx.translate(60,50)
ctx.rotate(-0.5)
//ctx.fillRect()
ctx.fillText(text,0,0)
return _wm.toDataURL()
}