我已经实现了pdf预览,但是我们要求实现所有文本文件的预览。
请问一下有什么好的office文件预览插件或者好方法没有,或者是前端能够实现文件转pdf的方法(我希望得到这类方法)。(拒绝网上说的利用在线office预览的功能)
<template>
<div class="pdf" v-show="fileType === 'pdf'">
<p class="arrow">
<span @click="changePdfPage(0)" class="turn" :class="{grey: currentPage==1}">Preview</span>
{{ currentPage }} / {{ pageCount }}
<span @click="changePdfPage(1)" class="turn" :class="{grey: currentPage==pageCount}">Next</span>
</p>
<pdf :src="src" :page="currentPage"
@num-pages="pageCount=$event"
@page-loaded="currentPage=$event"
@loaded="loadPdfHandler">
</pdf>
</div>
</template>
<script>
import pdf from 'vue-pdf'
export default {
components: {
pdf
},
data () {
return {
currentPage: 0,
pageCount: 0,
fileType: 'pdf',
src: ''
}
},
created () {
this.$bus.on('startPdfPreview', (val) => {
this.src = val
})
// this.src = pdf.createLoadingTask(this.src)
},
methods: {
changePdfPage (val) {
if (val === 0 && this.currentPage > 1) {
this.currentPage--
}
if (val === 1 && this.currentPage < this.pageCount) {
this.currentPage++
}
},
loadPdfHandler (e) {
this.currentPage = 1
}
}
}
</script>
<style>
span {
color: white;
}
</style>