pdfViewExample.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div class="pdf-view-example j-contanter">
  3. <div class="pdf-container j-main">
  4. <object :data="pdfUrl" type="application/pdf" width="100%" height="100%">
  5. <p>PDF 无法显示,请下载查看:<a :href="pdfUrl">下载 PDF</a></p>
  6. </object>
  7. </div>
  8. <div v-if="!getUserId" class="j-footer">
  9. <a href="/jyapp/free/login?back=index&to=back&activity=bidCreditReportPreview" class="adsense-container">
  10. <AdSingle
  11. ad="app-credit-report-sample"
  12. :show-tag="false"
  13. :show-close-icon="false"
  14. class="adsense-container"
  15. />
  16. </a>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. import { mapGetters } from 'vuex'
  22. import AdSingle from '@/components/ad/Ad'
  23. import { getAssetsFile } from '@/utils'
  24. export default {
  25. name: 'PdfViewExample',
  26. components: {
  27. AdSingle
  28. },
  29. data() {
  30. return {
  31. pdfUrl: ''
  32. }
  33. },
  34. computed: {
  35. ...mapGetters('user', ['getUserId'])
  36. },
  37. created() {
  38. const { pdfUrl } = this.$route.query
  39. if (pdfUrl) {
  40. this.pdfUrl = decodeURIComponent(pdfUrl)
  41. }
  42. else {
  43. const pdf = getAssetsFile('example.pdf')
  44. this.pdfUrl = pdf
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="scss" scoped>
  50. .pdf-container {
  51. width: 100%;
  52. height: 100%;
  53. iframe {
  54. width: 100%;
  55. height: 100%;
  56. }
  57. }
  58. </style>