本文共 1392 字,大约阅读时间需要 4 分钟。
Watermark-dom?????????????????????????????????????????Vue??????????????
???????npm????????
npm install watermark-dom --savenpm install js-cookie --save
?????????????????????
???Vue???????????????
import watermark from 'watermark-dom';import Cookies from 'js-cookie';
main.js?App.vue?????mounted??????????????????????????????????????????
export default { name: 'App', mounted() { setTimeout(() => { // ????????????????? const username = Cookies.get('username'); if (username) { const now = new Date(); const year = now.getFullYear(); const month = now.getMonth() + 1; const day = now.getDate(); // ???????????????? const monthStr = month < 10 ? `0${month}` : `${month}`; const dayStr = day < 10 ? `0${day}` : `${day}`; const dateStr = `${year}-${monthStr}-${dayStr}`; // ???? watermark.load({ watermark_txt: `${username},${dateStr}` }); } }, 1000); }}; month?day??????????watermark.load???????????????????????????????????????????Vue????????????????????cookie????????????????
转载地址:http://xisp.baihongyu.com/