Newer
Older
jh-business-system / src / views / business / taskMeasure / print / components / label / tempUse.vue
dutingting 28 days ago 566 bytes Initial commit: 项目初始化
<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>