📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

vue-doc-viewers-plus

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-doc-viewers-plus

A Vue 3 component for viewing various document types including PDF, Office documents and images

1.0.2
latest
Source
npm
Version published
Weekly downloads
8
100%
Maintainers
0
Weekly downloads
 
Created
Source

Vue Doc Viewers Plus

一个基于 Vue 3 的文档预览组件,支持 PDF、Office 文档和图片预览。

安装

npm install vue-doc-viewers-plus

使用方法

1. 引入组件和样式

import { DocViewerPlus } from 'vue-doc-viewers-plus'
import 'vue-doc-viewers-plus/dist/style.css'

2. 在模板中使用

<template>
  <doc-viewer-plus
    :file-url="fileUrl"
    :file-name="fileName"
    v-model:visible="visible"
  />
</template>

<script setup>
import { ref } from 'vue'
import { DocViewerPlus } from 'vue-doc-viewers-plus'
import 'vue-doc-viewers-plus/dist/style.css'

const fileUrl = ref('')
const fileName = ref('')
const visible = ref(false)

// 打开预览
const preview = () => {
  fileUrl.value = 'https://example.com/sample.pdf'
  fileName.value = 'sample.pdf'
  visible.value = true
}
</script>

预览效果

PDF 预览

PDF预览

Office 文档预览

Office预览

图片预览

图片预览

Props

属性名类型必填默认值说明
fileUrlstring-文件的 URL 地址
fileNamestring-文件名(用于下载时的文件名)
visiblebooleanfalse控制预览窗口的显示/隐藏

支持的文件类型

图片

  • jpg/jpeg
  • png
  • gif
  • bmp
  • webp

PDF

  • pdf

Office 文档

  • doc/docx(Word)
  • xls/xlsx(Excel)
  • ppt/pptx(PowerPoint)

特性

  • 支持图片预览和缩放
  • 支持 PDF 在线预览
  • 支持 Office 文档在线预览(使用微软 Office Online 服务)
  • 支持文件下载
  • 响应式设计
  • 支持 Vue 3 和 TypeScript

注意事项

  • Office 文档预览需要文件可以通过公网访问
  • 确保引入了组件样式文件 vue-doc-viewers-plus/dist/style.css

License

MIT

Keywords

vue

FAQs

Package last updated on 31 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts