微信小程序 canvas的文字居中显示

利用canvas的测量文本的measureText

ctx.fillText(str, (canvasWidth - ctx.measureText(str).width) / 2, 0);

你可能感兴趣的:(···,微信小程序,前端开发)