It is necessary to multiply the width and height of canvas by pixel ratio and scale the canvas. The official demo gives relevant writing methods
const query = wx.createSelectorQuery() query.select('#myCanvas') .fields({ node: true, size: true }) .exec((res) => { const canvas = res[0].node const ctx = canvas.getContext('2d') const dpr = Wx.getsysteminfosync ().pixelRatio // Canvas. Width = res[0]. Width * DPR canvas. Height = res[0]. Height * DPR ctx.scale(dpr, dpr) ctx.fillRect(0, 0, 100, 100) })Copy the code