Newer
Older
xc-business-system / src / views / business / taskMeasure / print / components / label / tempUse.vue
dutingting on 18 May 2024 566 bytes 1. bug修复
<script setup lang="ts">
import { ref } from 'vue'
import Canvas from '../components/canvas/canvas.vue'

const canvasComponent = ref(null)

function downloadImage() {
  const imageUrl = canvasComponent.value!.toImage()
  const link = document.createElement('a')
  link.href = imageUrl
  link.setAttribute('download', 'canvas.png')
  document.body.appendChild(link)
  link.click()
}
</script>

<template>
  <div>
    <canvas ref="canvasComponent" :width="55" :height="20" />
    <button @click="downloadImage">
      Download Image
    </button>
  </div>
</template>