|
|
пре 13 часа | |
|---|---|---|
| .hbuilderx | пре 1 месец | |
| common | пре 13 часа | |
| components | пре 13 часа | |
| hybrid | пре 3 недеља | |
| pages | пре 13 часа | |
| reqApi | пре 1 дан | |
| static | пре 13 часа | |
| store | пре 2 недеља | |
| style | пре 1 дан | |
| uni_modules | пре 13 часа | |
| unpackage | пре 3 недеља | |
| .gitignore | пре 3 недеља | |
| App.vue | пре 1 месец | |
| androidPrivacy.json | пре 3 недеља | |
| config.js | пре 1 месец | |
| index.html | пре 1 месец | |
| main.js | пре 3 недеља | |
| manifest.json | пре 13 часа | |
| package-lock.json | пре 3 недеља | |
| package.json | пре 13 часа | |
| pages.json | пре 1 дан | |
| polyfill.js | пре 3 недеља | |
| project.config.json | пре 1 месец | |
| project.private.config.json | пре 1 месец | |
| readme.md | пре 13 часа | |
| tsconfig.json | пре 3 недеља | |
| uni.promisify.adaptor.js | пре 1 месец | |
| uni.scss | пре 1 месец | |
| vite.config.js | пре 2 недеља |
支持在 H5 端预览 PDF、Word、Excel、PPTX、TXT 常见办公文件。提供页面跳转式预览与 API 直接调用两种集成方式,开箱即用。
uni_modules/wg-h5-preview-file 放入项目 uni_modules/ 目录。<wg-h5-preview-file /> 即可。uni-app 会自动按需注册
uni_modules下的组件,一般无需手动components注册。
基础用法(页面跳转方式中使用,被动接收 URL 与类型并立即展示):
<template>
<wg-h5-preview-file :value="file.url" :type="file.type" />
</template>
API 方式(在任意页面中通过 ref 主动打开预览):
<template>
<view>
<button @click="open">预览文件</button>
<wg-h5-preview-file ref="previewFile" />
</view>
</template>
<script>
export default {
data() {
return {
file: { url: "/static/demo.pdf", type: "pdf" },
};
},
methods: {
open() {
this.$refs.previewFile.preview({
url: this.file.url,
type: this.file.type,
});
},
},
};
</script>
value:String,必填。要预览的文件 URL。例如:/static/git.pdf。type:String,必填。文件类型,限定为:pdf | word | excel | pptx | txt。preview({ url, type }):
url:String,文件 URL。type:String,pdf | word | excel | pptx | txt。