Skip to content

Instantly share code, notes, and snippets.

@mibiio
Created June 3, 2020 08:51
Show Gist options
  • Save mibiio/a9551357170bbe0f0b4f2e8168e46681 to your computer and use it in GitHub Desktop.
Save mibiio/a9551357170bbe0f0b4f2e8168e46681 to your computer and use it in GitHub Desktop.
<template>
<q-page padding>
<q-pdfviewer
v-model="show"
type="pdfjs"
:src="pdfUrl"
content-class="absolute"
/>
</q-page>
</template>
<script>
import { axiosInstance } from 'boot/axios'
export default {
mounted () {
axiosInstance.get('/api/file',
{
responseType: 'arraybuffer'
}
).then(r => {
const blob = new Blob([r.data], { type: 'application/pdf' })
this.pdfUrl = window.URL.createObjectURL(blob)
this.show = true
})
},
data () {
return {
show: false,
pdfUrl: null
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment