-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.vue
57 lines (57 loc) · 1.08 KB
/
index.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<template>
</template>
<script>
import PDF from 'pdfobject/pdfobject.min.js'
export default {
props: {
type: {
type: Number,
default: 1
},
url: {
type: String,
default: ''
},
viewer: {
type: String,
default: ''
},
height: {
type: String,
default: '500px'
}
},
data: () => ({
pdf: null,
options: {
page: 1,
fallbackLink: '浏览器不支持PDF查看功能,请更换谷歌浏览器',
forcePDFJS: true
}
}),
created () {
if (this.type) {
// this.options.PDFJS_URL = 'http://mozilla.github.io/pdf.js/web/viewer.html'
this.options.PDFJS_URL = `${this.viewer}/pdfjs/web/viewer.html`
} else {
this.options.pdfOpenParams = {
navpanes: 0,
toolbar: 1,
statusbar: 1,
view: 'FitV',
pagemode: 'thumbs'
}
}
},
methods: {
loadPdf (url) {
this.pdf = PDF
this.pdf.embed(url, this.$el, this.options)
this.$el.style.height = this.height
}
},
mounted () {
this.loadPdf(this.url)
}
}
</script>