【发布时间】:2021-03-28 14:38:59
【问题描述】:
我正在尝试将 pdfjs 导入 VueJS 页面以获取 PDF 文件的标题(并使用它而不是 Web 查看器来呈现 PDF)但是当我导入 PDFJS 并将其输出到控制台时,我得到 @ 987654321@.
vue 文件:
<template lang="pug">
q-page
iframe#pdf(:height="height" width="100%" :src="url" :class="{ 'move-up-32-px': isMobile }")
</template>
<script>
import { pdfjs } from 'pdfjs-dist/webpack'
export default {
name: 'PDFViewer',
data () {
return {
name: '',
path: '/statics/pdfjs-2.5.207-dist/web/viewer.html',
height: '',
isMobile: false
}
},
computed: {
url: function () {
return this.path + '?file=' + this.name
}
},
mounted () {
this.name = window.location.protocol + '//' + window.location.host + '/' + this.$route.params.documentURL
this.height = window.innerHeight - 82 + 'px'
if (this.$q.platform.is.mobile) {
this.isMobile = true
this.height = window.innerHeight - 50 + 'px'
}
console.log(pdfjs) \\ undefined
}
}
</script>
package.json 依赖:
"dependencies": {
"@quasar/extras": "^1.6.0",
"@vue/composition-api": "^0.3.4",
"axios": "^0.18.1",
"electron-updater": "^4.2.5",
"quasar": "^1.9.10"
},
"devDependencies": {
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
"@quasar/app": "^1.6.0",
"@quasar/quasar-app-extension-dotenv": "^1.0.0",
"@quasar/quasar-app-extension-icon-genie": "^1.1.3",
"@vue/eslint-config-standard": "^4.0.0",
"babel-eslint": "^10.1.0",
"devtron": "^1.4.0",
"electron": "^9.0.0-beta.7",
"electron-builder": "^21.2.0",
"electron-debug": "^3.0.1",
"electron-devtools-installer": "^2.2.4",
"electron-packager": "^13.1.1",
"electron-rebuild": "^1.10.1",
"eslint": "^5.10.0",
"eslint-loader": "^2.1.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-vue": "^5.0.0",
"image-webpack-loader": "^6.0.0",
"pdfjs-dist": "^2.6.347",
"pug": "^2.0.4",
"pug-plain-loader": "^1.0.0",
"url-loader": "^2.3.0",
"worker-loader": "^3.0.6"
}
附言import { pdfjs } from 'pdfjs-dist/webpack' 和 import pdfjs from 'pdfjs-dist/webpack' 给出相同的结果
【问题讨论】: