我正在嘗試對一些 javascript 代碼進行故障排除,但我無法在 html 畫布上顯示任何 console.log 信息,以便我可以看到變量的值。有這樣做的基本方法嗎?// JavaScript Document/*jshint esversion: 6 */const canvas = document.getElementById('canvas1');const ctx = canvas.getContext('2d');canvas.width = window.innerWidth;canvas.height = window.innerHeight;console.log("Hello world!");alert("Just executed this code!");canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(10,10,153,0.5);}<!doctype html><html><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie-edge"> <title>Art01a2020</title> <link rel="stylesheet" href="style4.css"></head><body> <canvas id="canvas1"></canvas> <script type="text/javascript" src="script4.js"></script></body></html>
使用console.log在canvas中進行javascript故障排除
滄海一幻覺
2023-06-29 21:06:32