首页 > 解决方案 > 使用画布绘制不同形式的日期

问题描述

我想画一种不同形式的日期,像这样:

  1. 2019/01/07
  2. 2019.01.07
  3. 2019-01-07
  4. 2019/01/00٧
  5. 2019.01.00
  6. 2019-01-00号
  7. 2019 年 1 月 7 日(使用不同的语言)

代码:

function click() {
    var canvas = document.getElementById("canvas");
    var context = canvas.getContext("2d");
    var carta = new Image();
    carta.src = "national.jpg"
    var t_milade = document.getElementById("t_milade").value;
    carta.onload = function(){
        context.drawImage(carta, 0, 0, 728, 546);
        context.font = "900 35px Alfa Slab One";
        context.fillStyle = "#181818";
        context.textAlign = "right";
        context.fillText(t_milade, 262, 440);
    }  
}

标签: javascripthtml

解决方案


推荐阅读