<canvas id="mycanvas3" width="400" height="400"></canvas>
let canvas = document.getElementById('mycanvas3')
if (canvas.getContext) {
  let ctx = canvas.getContext('2d')
  ctx.beginPath()
  ctx.moveTo(20,20)
  ctx.lineTo(60, 20)
  ctx.lineTo(40,50)
  ctx.lineTo(20,20)
  ctx.closePath()
  ctx.stroke()
} else {
  console.log('浏览器不支持canvas')
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.