Vue โ
vue-pdf โ
vue
<template>
<div>
<pdf ref="pdf" v-for="i in numPages" :key="i" :src="url" :page="i"></pdf>
</div>
</template>
<script>
import pdf from 'vue-pdf'
export default {
components: {
pdf
},
data() {
return {
url: "/static/resume.pdf",
numPages: null, // pdf ๆป้กตๆฐ
}
},
mounted() {
this.getNumPages()
},
methods: {
// ่ฎก็ฎpdf้กต็ ๆปๆฐ
getNumPages() {
let loadingTask = pdf.createLoadingTask(this.url)
loadingTask.promise.then(pdf => {
this.numPages = pdf.numPages
}).catch(err => {
console.error('pdf ๅ ่ฝฝๅคฑ่ดฅ', err);
})
},
}
}
</script>