代码
提交代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>慕课网Wiki</title> <style> #imooc{ border:1px solid #ccc; } </style> </head> <body> <canvas id="imooc">您的浏览器不支持 HTML5 canvas 标签</canvas> <script> const canvas = document.getElementById('imooc'); const ctx = canvas.getContext('2d'); ctx.strokeStyle="blue"; ctx.lineWidth=8; ctx.strokeRect(10,10,200,100); //调用了直接绘制并渲染矩形函数 </script> </body> </html>
运行结果