this.gradeList.forEach((item, index) => {
if (this.changeIndex >= item.index) {
ctx.drawImage(okpng, 32, 260 + (index + 1) * 30, 18, 16);
ctx.setFontSize(15);
ctx.setFillStyle("#80442B");
ctx.textAlign = "left";
ctx.fillText(item.title, 61, 275 + (index + 1) * 30);
}
});
需要用 wx.getImageInfo 将图片转成临时路径,这样在真机上就能正常预览了
wx.getImageInfo({ src: okpng,//服务器返回的图片地址 success: function (res) { //res.path是网络图片的本地地址 let Path = res.path; ctx.drawImage(Path, 32, 260 + (index + 1) * 30, 18, 16); }, fail: function (res) { //失败回调 } });