javascript html画布中的换行符
我制作了一个HTML画布,我想在画布文本中用户名变量后加一个分隔符,但它无法识别我迄今为止尝试过的换行符,例如javascript html画布中的换行符,javascript,canvas,line-breaks,Javascript,Canvas,Line Breaks,我制作了一个HTML画布,我想在画布文本中用户名变量后加一个分隔符,但它无法识别我迄今为止尝试过的换行符,例如\n或。这是密码 function drawText() { let startText = "Welcome "+username+"You've answered "+questionCount+" out of 10"; ctx.font = '30px Calibri';//size and type of fo
\n
或
。这是密码
function drawText() {
let startText = "Welcome "+username+"You've answered "+questionCount+" out of 10";
ctx.font = '30px Calibri';//size and type of font
ctx.fillStyle = "#f0f0f0";//colour of font
ctx.textAlign = "center";
ctx.fillText(startText, 350, 350);
}
window.addEventListener("load", drawText(), false);
您在哪里定义了ctx。。。请完整地输入代码。我想你的问题以前被问过。。。