新的canvas文字如何设置居中?
const ctx = canvas.getContext('2d');
ctx.setTextAlign('center');
这样直接报错了:
ctx.setTextAlign is not a function
TypeError: ctx.setTextAlign is not a function
我现在用 measureText 这个方法获取文字宽度,然后来设置,但是这样的话,不是很准
const ctx = canvas.getContext('2d');
ctx.setTextAlign('center');
这样直接报错了:
ctx.setTextAlign is not a function
TypeError: ctx.setTextAlign is not a function
我现在用 measureText 这个方法获取文字宽度,然后来设置,但是这样的话,不是很准