新的canvas文字如何设置居中?
发布于 6 年前 作者 jingsong 14294 次浏览 来自 官方Issues
const ctx = canvas.getContext('2d');
ctx.setTextAlign('center');

这样直接报错了:

ctx.setTextAlign is not a function
TypeError: ctx.setTextAlign is not a function

 我现在用 measureText 这个方法获取文字宽度,然后来设置,但是这样的话,不是很准

回到顶部