JSFiddle - React, Tailwind, and code Playground

HTML

<title></title>
        <script>
                window.onload = function(){
                        var oC = document.getElementById('ch1');
                        var oGC = oC.getContext('2d');

                        function drawClock(){
                                var x = 200;   //指定坐标
                                var y = 200;
                                var r = 150;  //指定钟表半径

                                oGC.clearRect(0,0,oC.width,oC.height);//清空画布

                                var oDate = new Date();      //创建日期对象
                                var oHours = oDate.getHours();//获取时间
                                var oMin = oDate.getMinutes();
                                var oSen = oDate.getSeconds();

                                var oHoursValue = (-90 + oHours*30 + oMin/2)*Math.PI/180; //设置时针的值
                                var oMinValue = (-90 + oMin*6)*Math.PI/180;
                                var oSenValue = (-90 + oSen*6)*Math.PI/180;

                                oGC.beginPath();//开始

                                for(var i=0;i<60;i++){         //i为60,代表着时钟的60个小刻度
                                        oGC.moveTo(x,y);
                                        oGC.arc(x,y,r,6*i*Math.PI/180,6*(i+1)*Math.PI/180,false); //循环从6度到12度
                                }
                                oGC.closePath();
                                oGC.stroke();

                                oGC.fillStyle ='white'; //覆盖住小刻度的黑色线
                                oGC.beginPath();
                                oGC.moveTo(x,y);
                                oGC.arc(x,y,r*19/20,0,360*(i+1)*Math.PI/180,false);

                                oGC.closePath();//结束
                                oGC.fill();

                                oGC.lineWidth = 3; //设置时钟圆盘大刻度的粗细值
                                oGC.beginPath();  //开始画大的时钟刻度

                                for(i=0;i<12;i++){              //i为12,代表着时钟刻度的12大格
    ...