Canvas与Div层级设置 显示当前时间

1,Div放在Canvas上面:

  Div的position设为fixed或absolute

2,鼠标穿透上层的div,操作下层的Canvas

  设置div的pointer-events:none即可

3,Echarts背景图设置:background-image:url('./image.png')

 

4, 显示当前时间 并自动刷新

<script type="text/javascript">
        var t = null;
		t = setInterval("getTime();",1000); //每隔一秒运行一次
	
	    //取得系统当前时间
        function getTime(){
            var myDate = new Date();
            var date = myDate.toLocaleDateString();
            var hours = myDate.getHours();
            var minutes = myDate.getMinutes();
            var seconds = myDate.getSeconds();
            //将值赋给div
            document.getElementById("currentTime").innerHTML = date+" "+hours+":"+minutes+":"+seconds;
        }
    </script>

  

posted @ 2022-03-20 09:13  VTech_kevin  阅读(509)  评论(0编辑  收藏  举报