Vue3实现word预览

1. 安装依赖
pnpm install @vue-office/docx
2. 页面导入
// 导入依赖
import VueOfficeDocx from "@vue-office/docx";
// 导入样式文件
import "@vue-office/docx/lib/index.css";
3. 使用(这里使用是文件上传方式)可以直接是在线地址
<script setup>
import VueOfficeDocx from "@vue-office/docx";
import "@vue-office/docx/lib/index.css";
import { ref } from "vue";
// 也可以直接是在线地址
// let docxSrc = ref("https://github.com/vue-office/vue-office/raw/main/examples/public/test.docx");
let docxSrc = ref("");
let handleChange = (e) => {
  let files = e.target.files[0];
  let reader = new FileReader();
  reader.readAsArrayBuffer(files);
  reader.onload = function () {
    docxSrc.value = reader.result;
  };
};
</script>

<template>
  <div>
    <input type="file" @change="handleChange" />
    <VueOfficeDocx :src="docxSrc" />
  </div>
</template>

<style scoped></style>

这样就可以实现word文件预览了 是不是很简单

相关推荐

  1. Vue3实现word

    2024-07-20 05:16:04       19 阅读
  2. vue pdf、word、excel

    2024-07-20 05:16:04       55 阅读
  3. vue2 word文件

    2024-07-20 05:16:04       37 阅读
  4. vue3 H5项目中实现PDF

    2024-07-20 05:16:04       50 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-20 05:16:04       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-20 05:16:04       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-20 05:16:04       45 阅读
  4. Python语言-面向对象

    2024-07-20 05:16:04       55 阅读

热门阅读

  1. cephrgw元数据和数据布局

    2024-07-20 05:16:04       16 阅读
  2. ArcGIS Pro SDK (九)几何 11 几何包

    2024-07-20 05:16:04       15 阅读
  3. vue3前端开发-小兔鲜项目-一级页面banner图渲染

    2024-07-20 05:16:04       17 阅读
  4. day04.03.python中的for循环

    2024-07-20 05:16:04       17 阅读
  5. Apple Vision Pro 开发资源大全

    2024-07-20 05:16:04       14 阅读
  6. mysql 浮点数类型

    2024-07-20 05:16:04       16 阅读
  7. stack

    2024-07-20 05:16:04       16 阅读
  8. DGPU共享内存的问题

    2024-07-20 05:16:04       17 阅读
  9. 阿里云服务器 篇三:提交搜索引擎收录

    2024-07-20 05:16:04       18 阅读
  10. python 打包工具 nuitka 使用笔记

    2024-07-20 05:16:04       16 阅读