+
52
-

uni.canvasToTempFilePath如何导出比canvas尺寸大几倍的图片?

uni.canvasToTempFilePath如何导出比canvas尺寸大几倍的图片?


网友回复

+
14
-

可以修改uni.canvasToTempFilePath的destWidth和destHeight参数实现:

<template>
  <view class="container">
    <canvas canvas-id="myCanvas" id="myCanvas" class="canvas"></canvas>
    <button type="primary" @click="exportImage">导出大图</button>
  </view>
</template>

<script>
export default {
  data() {
    return {
      canvasWidth: 300, // Canvas 宽度
      canvasHeight: 300, // Canvas 高度
      scale: 3 // 放大倍数
    };
  },
  methods: {
    drawCanvas() {
      const ctx = uni.createCanvasContext('myCanvas', this);
   ...

点击查看剩余70%

我知道答案,我要回答