<template>
  <div>123</div>
</template>

<script setup>
import { Document, Packer, Paragraph, TextRun } from 'docx';

// 创建文档
const doc = new Document({
  sections: [
    {
      properties: {},
      children: [
        new Paragraph({
          text: 'Hello World',
          heading: 'Heading1'
        }),
        new Paragraph({
          text: 'This is a simple DOCX file created using DOCX.js.'
        })
      ]
    }
  ]
});

const download = async (doc) => {
  const blob = await Packer.toBlob(doc);
  const link = document.createElement('a');
  link.href = URL.createObjectURL(blob);
  link.download = 'document.docx';

  // Click the link to download the file
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
};
// download(doc)
</script>

<style scoped></style>
