react-watermark-component is a component that can generate a water mark background image.
npm install yd-react-watermark-component
- react-watermark-component is a component that can generate a water mark background image.
- this react component is from an internal project of youzan company.
``shell`
yarn add react-watermark-component
or
`shell`
npm i react-watermark-component --save
`javascript`
import ReactWaterMark from 'react-watermark-component';
or you can also load as follows:
`javascript`
const ReactWaterMark = require('react-watermark-component')
- openSecurityDefense:bool, decide whether to open security defense. By default, the security defense isn't opened.
- securityAlarm:function, when the security defense is opened and water mark is attacked, the securityAlarm callback will be called. The securityAlarm props is optional, it will be triggered when someone is deleting the water mark dom or modifying the style attribute of the water mark dom.
- options:object, the options is optional, the default value of the field of the options object is as follows.
| option | default value |200
| --------- | ------------- |
| chunkWidth | |60
| chunkHeight | |'left'
| textAlign | |'bottom'
| textBaseline | |0.17
| globalAlpha | |'14px Microsoft Yahei'
| font | |-0.26
| rotateAngle | |'#666'
| fillStyle | |
- chunkWidth:number, the width of a piece of water mark, it's suggested that the value is more than the real width, such as the real width is 150, correspondingly the chunkWidth is 200
- chunkHeight:number, the height of a piece of water mark, it's suggested that the value is at least four times than the font-size of the real water mark text
`javascript${loginedUser.cas_username}, ${loginedUser.cas_id}
render() {
const text = ;`
const beginAlarm = function() { console.log('start alarm'); };
const options = {
chunkWidth: 200,
chunkHeight: 60,
textAlign: 'left',
textBaseline: 'bottom',
globalAlpha: 0.17,
font: '14px Microsoft Yahei',
rotateAngle: -0.26,
fillStyle: '#666'
}
return (
openSecurityDefense
securityAlarm={beginAlarm}
options={options}
>
...
)
}
`shell``
npm run build