【微信小程序】设置画布字体

得将属性设置写在fillText的前面,否则不起作用

    var context = wx.createCanvasContext('canvas')
    context.setFontSize(10); //设置字体大小
    context.setTextAlign('center'); //设置字体水平居中
    context.setTextBaseline('middle') //设置文字的竖直对齐方式为居中
    context.setFillStyle('#ffffff'); //设置字体颜色为白色
    context.fillText( 'hello world', 0, 0);

你可能感兴趣的:(微信小程序,微信小程序,css,小程序)