提交 ab3dfc2c 编写于 作者: H hdx

canvas: canvasToBlob 仅web可见

上级 25834287
......@@ -2,7 +2,9 @@
<view class="page" id="page-canvas">
<canvas id="canvas" class="canvas-element"></canvas>
<scroll-view class="scroll-view">
<!-- #ifdef WEB -->
<button class="canvas-drawing-button" @click="canvasToBlob">canvasToBlob</button>
<!-- #endif -->
<button class="canvas-drawing-button" @click="canvasToDataURL">canvasToDataURL</button>
<text>{{dataBase64}}</text>
</scroll-view>
......@@ -49,13 +51,13 @@
this.canvas = canvas;
},
methods: {
canvasToBlob() {
// #ifdef WEB
canvasToBlob() {
this.canvas!.toBlob((blob : Blob) => {
this.testToBlobResult = (blob.size > 0 && blob.type == 'image/jpeg')
}, 'image/jpeg', 0.95)
// #endif
},
// #endif
canvasToDataURL() {
this.dataBase64 = this.canvas!.toDataURL()
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册