博客
关于我
Vue中使用 watermark-dom 添加水印
阅读量:239 次
发布时间:2019-02-28

本文共 1367 字,大约阅读时间需要 4 分钟。

Watermark-dom?????????????????????????????????????????Vue??????????????

????

???????npm????????

npm install watermark-dom --savenpm install js-cookie --save

?????????????????????

?Vue?????

???Vue???????????????

  • ?????Cookie????
  • import watermark from 'watermark-dom';import Cookies from 'js-cookie';
    1. ?Vue????????main.js?App.vue?????mounted????????????
    2. ??????

      ??????????????????????????????

      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);    }};

      ????

      • cookie???????????????cookie???????????
      • ?????????????????????month?day??????????
      • ?????????watermark.load???????????????????????????????

      ????????????Vue????????????????????cookie????????????????

    转载地址:http://xisp.baihongyu.com/

    你可能感兴趣的文章
    PYTHON中的主体对象标识
    查看>>
    Python中的修饰函数始终返回NONE
    查看>>
    Python中的元素相乘与矩阵相乘(附Demo)
    查看>>
    Python中的分组/聚类数字
    查看>>
    python中的十六进制字符串到字节数组
    查看>>
    Python中的单元测试框架:使用unittest进行有效测试
    查看>>
    Python中的压缩和解压缩模块:zipfile和tarfile
    查看>>
    python中的变量可以随时命名、随时赋值_python基础2
    查看>>
    PYTHON中的可变和不可变字符串
    查看>>
    Python中的多个元组到两对元组?
    查看>>
    Python中的多态性
    查看>>