在vue3中实现pptx、word、excel预览

插件推荐

PPTXjs
vue-office

代码

<script setup lang="ts" name="home">
import { computed, nextTick, ref, onMounted } from 'vue';
//引入VueOfficeDocx组件
import VueOfficeDocx from '@vue-office/docx';
//引入VueOfficeExcel组件
import VueOfficeExcel from '@vue-office/excel';
//引入相关样式
import '@vue-office/docx/lib/index.css';
const docx = ref('/file/test.docx'); //设置文档网络地址,可以是相对地址
const excel = ref('/file/test.xlsx'); //设置excel网络地址,可以是相对地址
const pptx = ref('/file/test.pptx'); //设置ppt网络地址,可以是相对地址

const renderedHandler = () => {
  console.log('渲染完成');
};
const errorHandler = () => {
  console.log('渲染失败');
};
</script>

<template>
  <div>
    <h1>PPT文档预览</h1>
    <iframe :src="`/PPTXjs-1.21.1/index.html?file=` + pptx" width="100%" height="900" frameborder="0"></iframe>
    <h1>word文档预览</h1>
    <vue-office-docx :src="docx" style="width: 100%; height: 900px" @rendered="renderedHandler" @error="errorHandler" />
    <h1>excel预览</h1>
    <vue-office-excel
      :src="excel"
      style="width: 100%; height: 900px"
      @rendered="renderedHandler"
      @error="errorHandler"
    />
  </div>
</template>

<style scoped></style>

在这里插入图片描述

pptxjs 文件传递

需要在 index.html 中获取文件地址
在这里插入图片描述

相关推荐

  1. vue3 H5项目实现PDF

    2024-04-13 05:10:02       57 阅读
  2. Vue3实现word

    2024-04-13 05:10:02       23 阅读
  3. Vue使用v-viewer插件实现点击图片

    2024-04-13 05:10:02       34 阅读
  4. vue3+vite使用viewerjs实现图片

    2024-04-13 05:10:02       31 阅读
  5. vue3之基于el-image实现图片

    2024-04-13 05:10:02       29 阅读
  6. vue实现图片

    2024-04-13 05:10:02       28 阅读

最近更新

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

    2024-04-13 05:10:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-13 05:10:02       101 阅读
  3. 在Django里面运行非项目文件

    2024-04-13 05:10:02       82 阅读
  4. Python语言-面向对象

    2024-04-13 05:10:02       91 阅读

热门阅读

  1. Objective-C网络请求开发的高效实现方法与技巧

    2024-04-13 05:10:02       42 阅读
  2. C++ 设计模式

    2024-04-13 05:10:02       39 阅读
  3. mysqlySQL中启用慢查询日志并设置阈值

    2024-04-13 05:10:02       34 阅读
  4. 大模型日报2024-04-12

    2024-04-13 05:10:02       47 阅读
  5. Kafka

    Kafka

    2024-04-13 05:10:02      25 阅读
  6. props组件传值(子串子)

    2024-04-13 05:10:02       32 阅读
  7. postgresql命令

    2024-04-13 05:10:02       32 阅读