//axml
<view> <canvas
id="canvas"
width="610"
height="610"
class="canvas"
ontouchstart="log"
ontouchmove="log"
ontouchend="log"
/><image mode="widthfix" src="{{dataimage}}"/>view>
//js
data: {
dataimage:"",},
onload(){
const ctx = my.createcanvascontext('canvas');
ctx.setfillstyle('#108ee9');
ctx.arc(50, 50, 50, 0, math.pi * 2, true);
ctx.fill(); ctx.draw(); //可通过设置filetype和quality来设置图片的格式和质量
ctx.todataurl({
x: 50,
y: 50,
width: 50,
height: 50,
destwidth: 100,
destheight: 100,
}).then(dataurl=>{
ctx.drawimage(dataurl, 0, 0);
console.log("dataurl", dataurl)
this.setdata({
dataimage:dataurl
})
ctx.draw();
})
}
